hi all
i got problem on JProgress bar. when i click on button progress doesn't show. it display after completing the progress

class A{
//button clic
ProgressBar frame = new ProgressBar();
    frame.pack();
    frame.setVisible(true);
    frame.iterate( );
class ProgressBar extends JFrame //inner class of A
  {
      JLabel l1;
      JProgressBar current;

     Thread runner;
     int num = 0;
public ProgressBar()
{
     super("Maze ProgressBar");

     JPanel pane = new JPanel();
     pane.setLayout(new GridLayout());
     current = new JProgressBar(0, 100);
     current.setValue(0);
     current.setStringPainted(true);
     pane.add(current);
     setContentPane(pane);

}


     public void iterate()
{
     while (num < 1000) 
{
     current.setValue(num);
     try 
{
     Thread.sleep(500);
 }
     catch (InterruptedException e)
 {


 }
    num += 90;
 }
 }


}

pls help me where i m making mistake. thx

i really need help. pls help me. pls.

It probably has to do with the fact that you're not starting any threads, or at least not properly, but I have no desire to have yet another long "discussion" about threads and the Swing Event Thread only to have it go nowhere, which is what always seems to happen as soon as someone asks this type of question.

So, one last hint, it probably has to do with performing actions on the Swing Event Thread rather than in their own thread.

masijade is exactly right. You are looping and waiting in the Swing event thread, which blocks all GUI activity (including repainting the progress bar) until your method finishes.
You'll find lots of info on this here at Daniweb, and via Google (search for Java event dispatch thread)

But i could not figure it out how to display the progress of it pls help meh if any one knows bout it ?

can i see the example code pls if you can thank you

You will learn a lot more if you read the doc and try to do this yourself. Have a go, then post what you've got and we'll help from there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.