I need to show the progress bar when i click in a button and the progress is related with the information that shows a jtextpane.
this is the method of the progress bar
private JProgressBar getMethodsjProgressBar() {
if (methodsjProgressBar == null) {
methodsjProgressBar = new JProgressBar();
methodsjProgressBar.setVisible(false);
methodsjProgressBar.setStringPainted(true);
methodsjProgressBar.setBounds(new Rectangle(20, 244, 103, 22));
methodsjProgressBar.setString("Cargando...");
}
return methodsjProgressBar;
}
and this one is the button
private JButton getLoadMethodsButton() {
if (loadMethodsButton == null) {
loadMethodsButton = new JButton();
loadMethodsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
FileChooserDirectory.getInstance().getAddress();
@SuppressWarnings("unused")
LoadClass loadClass = new LoadClass();
methodsjProgressBar.setVisible(true);
}
});
loadMethodsButton.setText("Buscar clase");
loadMethodsButton.setBounds(237, 255, 126, 26);
}
return loadMethodsButton;
}
i need to know what i have to do to change the jprogressbar value when i'm loading the class
Suggestions:
setProgress(...)
to a value between 0 and 100, add a PropertyChangeListener to your SwingWorker and listen for changes to the progress property, and then use this data to update your JProgressBar. null
layouts and setBounds(...)
since this will result in very rigid GUI's that are difficult to update or maintain. If you need more detailed help, consider creating and posting a minimal example program
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.