当我点击按钮时,我需要显示进度条,并且进度与显示jtextpane的信息有关。
这是进度条的方法
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;
}
这个是按钮
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;
}
我需要知道在我加载课程时我需要做些什么才能更改jprogressbar值
答案 0 :(得分:0)
建议:
setProgress(...)
将progress属性设置为0到100之间的值,将一个PropertyChangeListener添加到你的SwingWorker并监听progress属性的变化,然后使用此数据更新JProgressBar。null
布局和setBounds(...)
,因为这会导致非常严格的GUI难以更新或维护。如果您需要更详细的帮助,请考虑创建和发布最小示例程序