I have a program where when the user clicks a certain button I want a small new frame to appear with a progress bar. I do not want the user to be able to do any other thing until the process is finished. I am having troubles updating the progress bar when I place it in a separate frame that pops up when the button is pressed. If I place the progress bar in the same panel as the button then it updates correctly, but this is not what I want. I need it to be in a new frame and I need the user to have to wait for it to finish. How can I do that? Thanks.
I create the frame with the following code:
void designProgressFrame() {
progressFrame = new JFrame("Progress");
progressFrame.getContentPane().setLayout(new BoxLayout(progressFrame.getContentPane(), BoxLayout.PAGE_AXIS));
progressFrame.setSize(200, 100);
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
panel1.setBackground(new Color(248, 248, 244));
panel2.setBackground(new Color(248, 248, 244));
progressFrame.getContentPane().setBackground(new Color(248, 248, 244));
progressBar = new JProgressBar();
progressBar.setStringPainted(true);
progresslbl = new JLabel();
panel1.add(progressBar);
panel2.add(progresslbl);
progressFrame.getContentPane().add(panel1);
progressFrame.getContentPane().add(panel2);
progressFrame.setLocationRelativeTo(null);
}
and once a certain button is pressed in my main program I make this frame visible and start updating the progress bar using the setValue() method, but for some reason the bar is not updated.