Help with JProgressBar

I understand that there were a lot of posts and examples involving JProgressBar. I understood the concepts of threads too. I started implementing a simple application where the program actuallytries to get information from a database. As the retrieval takes some time, I want to display an indeterminate progress bar in a pop-up dialog box which gets disposed once the retrieval is done. Here is the code...

// CODE IN MY MAIN PROGRAM WHICH CALLS BOTH THE THREAD AND THE BACKGROUND PROCESS

myThread mT =new myThread("Please wait...!!!");

mT.start();

if (jComboBoxUserName.getSelectedIndex() > 0)

hardWareItems = dataIO.getHardWareInfo(argumentsList);// trying to retrieve information from the DB

else

hardWareItems = dataIO.getHardWareInfo("empty", sqlStmt);// trying to retrieve information from the DB

mT.pleaseStop();

// MYTHREAD CODE WHICH CALLS THE CLASS TO LOAD THE DIALOG BOX

class myThreadextends Thread{

String labelText;

boolean stillRunning =true;

LoadingWindow LW;

myThread(String labelText){

this.labelText = labelText;

LW =new LoadingWindow(labelText);

}

publicvoid run(){

Dimension screenSize = Toolkit.getDefaultToolkit().

getScreenSize();

Dimension frameSize = LW.getSize();

if (frameSize.height > screenSize.height){

frameSize.height = screenSize.height;

}

if (frameSize.width > screenSize.width){

frameSize.width = screenSize.width;

}

LW.setLocation((screenSize.width - frameSize.width) / 2,

(screenSize.height - frameSize.height) /

2);

LW.show();

while (this.stillRunning){

LW.repaint();

}

if (!this.stillRunning){

LW.dispose();

}

}

publicvoid pleaseStop(){

this.stillRunning =false;

}

}

// THE DIALOG BOX WHICH POPS UP CONTAINING THE LABEL AND PROGRESSBAR

publicclass LoadingWindowextends JDialog{

public LoadingWindow(String labelText){

this.labelText = labelText;

try{

jbInit();

}catch (Exception ex){

ex.printStackTrace();

}

}

privatevoid jbInit()throws Exception{

this.setSize(200,75);

jLabel1.setText("<html><b><align = center>"+labelText+"</b></html>");

this.getContentPane().setLayout(new GridLayout(2,0));

this.getContentPane().add(jLabel1);

this.getContentPane().add(jProgressBar1);

jProgressBar1.setIndeterminate(true);

this.repaint();

jProgressBar1.setStringPainted(true);

}

JLabel jLabel1 =new JLabel();

JProgressBar jProgressBar1 =new JProgressBar();

String labelText;

}

Everything is getting executed, the dialog box pops up... but I am not able to see the label and progressbar in it until the background process is completed. As far as I understand, it is a seperate thread, but still not updating. I would really appreciate if anyone could point out where I am going wrong.

[5041 byte] By [Bristle-a-jinksa] at [2007-10-3 7:14:24]
# 1
here's a post that you can copy/paste/compile/run and see a working example http://forum.java.sun.com/thread.jspa?threadID=693345&start=6compare to yours, see what's different
Michael_Dunna at 2007-7-15 2:10:47 > top of Java-index,Desktop,Core GUI APIs...