I have a GUI problem that I would like to get sorted out, but I am baffled as to what's happening and hope one of you can explain it. The code base is way too large to upload however I will explain in detail what's happening:
I have a class ProgessBar
which is a JDialog
containing a swing JProgressBar
. I have some getters and setters to change the bar to my liking however here comes the issue.
The ProgressBar is spawned inside of a method myButtonActionPerformed
myButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
myButtonActionPerformed(evt);
}
});
essentially when the user hits this button, the processing begins and the ProgressBar
is spawned.
The user currently has a JFrame
in front of them and this progress bar is popped up in a JDialog
. After stepping through debug mode in Netbeans, I can see the JProgressBar
's values getting changed, but the bar visually stays at 0% while my program is processing then instantly jumps to 100% the moment it leaves the add action listener method above, almost as if it was waiting to repaint until out of that listener. What am I not understanding? Is there something I can call that will force it to update inside of this myButtonActionPerformed
method instead of waiting until it's useless.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…