Possible Duplicate:
JDialog Stops execution of parent JFrame
I have to JFrame and it has undecorated and has only an image of progress bar in it...but when i want send request to the server i want it to be show progress bar and it is not showing it instead but my window is loaded....i have tried jDialog but it is stopping execution of my code..
here is my code
private void LoginBtnActionPerformed(java.awt.event.ActionEvent evt) {
ProgressBar pb = new ProgressBar();
pb.setVisible(true);
List<BasicNameValuePair> postPairs = new ArrayList<BasicNameValuePair>();
AsyncService asyncService = new AsyncService();
postPairs.add(new BasicNameValuePair("PATH","authenticateUser.idoc"));
postPairs.add(new BasicNameValuePair("user_email",email));
postPairs.add(new BasicNameValuePair("user_password",password));
JSONArray jArray = asyncService.sendRequest(postPairs);
pb.setVisible(true);
}
I have nothing in my progress bar frame except an gif animation image and a Label... EDIT 1 */
class WorkerProgressBar extends SwingWorker<Integer, Integer>
{
private JFrame pb = new JFrame();
JDialog dialog = new JDialog();
JPanel panel = new JPanel();
JLabel label = new JLabel();
public WorkerProgressBar(){
panel = new JPanel();
panel.setBackground(new Color(114,114,114));
JLabel imageLabel = new JLabel(new ImageIcon(getClass().getResource("/icons/progress_bar.gif")));
imageLabel.setBorder(BorderFactory.createLineBorder(Color.black));
panel.add(imageLabel);
dialog.getContentPane().add(panel,BorderLayout.CENTER);
dialog.pack();
dialog.setLocationRelativeTo(null);
}
protected Integer doInBackground() throws Exception
{
dialog.setVisible(true);
return 0;
}
protected void done()
{
try
{
dialog.setVisible(false);
}
catch (Exception e)
{
e.printStackTrace();
}
}