Peter said:
Without a concise-but-complete code sample demonstrating the problem,
it's impossible to say. But, it sounds as though you are executing the
work in response to the button press from the Action event handler. If
so, then you're blocking the event-dispatch thread, preventing your
JFrame from being able to redraw its contents, or any other UI events
for that matter.
If that turns out to be the case, then you should be moving your lengthy
processing to a different thread, and let the EDT do its thing.
If that's not the case, then you should post a more specific, more
complete question.
Pete
In the init method the frame is defined:
-----------------------------------------------------------
jpb = new JProgressBar(0, 100);
jpb.setPreferredSize(new Dimension(170, 20));
jf = new JFrame("Title");
jf.setLayout(new FlowLayout(FlowLayout.CENTER));
jf.setPreferredSize(new Dimension(300, 90));
jf.setLocation(190, 90);
jf.getContentPane().add(new JLabel("Please wait..."));
jf.getContentPane().add(jpb);
jf.pack();
jf.setVisible(false);
-----------------------------------------------------------
Then it is set visible in the action performed of the button:
---------------------------------------------------------------------------
private void myButtonActionPerformed(java.awt.event.ActionEvent evt)
{
if(!jf.isVisible())
{
jf.setVisible(true);
//some processing that takes a couple of seconds
}
}
----------------------------------------------------------------------------