[英]How can I relate a JProgressBar with other component?
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. 当我单击按钮时,我需要显示进度栏,并且进度与显示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 我在加载类时需要知道更改jprogressbar值的方法
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. setProgress(...)
将progress属性设置为0到100之间的值,向您的SwingWorker添加PropertyChangeListener并侦听对progress属性的更改,然后使用此数据更新您的JProgressBar。 null
layouts and setBounds(...)
since this will result in very rigid GUI's that are difficult to update or maintain. null
布局和setBounds(...)
因为这将导致非常僵化的GUI,难以更新或维护。 If you need more detailed help, consider creating and posting a minimal example program 如果您需要更多详细的帮助,请考虑创建并发布一个最小的示例程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.