• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 927
  • Last Modified:

Jdialog doesn't hide as I click OK button

here is my Code

dialog=new JDialog(this,"",true);
....
dialog.show();
dialog.hide();
dialog.dispose();
....
if (isOK) {             // OK was typed
...here is long runing query..........


}
only after query finishes, jdialog dissapers. no matter where I place hide or dispose.
even inside actionperformed block. what does it mean? can I somehow handle
the situation? ( remove jdialog at once?)? I want to show a new dialog with clock
calculating query time

Thanks
0
kako
Asked:
kako
  • 5
  • 4
1 Solution
 
TimYatesCommented:
dialog.hide();
Thread.yield() ;
...
0
 
TimYatesCommented:
Swing runs in a seperate thread to your processing, so if you do something processor-hungry, calling Thread.yield() allows the Swing thread to do its repainting :-)
0
 
kakoAuthor Commented:
what you say seems to be quite reasonable, but not helps :)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
kakoAuthor Commented:
what you say seems to be quite reasonable, but not helps :)
0
 
TimYatesCommented:
It still doesn't vanish?

Can you post the code which calls the dialog, and the dialog code?
0
 
kakoAuthor Commented:
it's huge :(

here is part of code

void real_actionPerformed() {
   int sizeX=400, sizeY=300;
   inffo = new JDialog(this,"",true);
   inffo.setResizable(false);
   inffo.getContentPane().setLayout(new XYLayout());
   inffo.setSize(new Dimension(sizeX,sizeY));
   inffo.setLocation((ssx+20-sizeX)/2,(ssy-sizeY)/2);
         inffo.getContentPane().add(header,new XYConstraints( 135, 8, 200, 20));
         inffo.getContentPane().add(month_start,new XYConstraints( 20, 35, 100, 20));
         inffo.getContentPane().add(year_start,new XYConstraints( 125, 35, 60, 20));
         inffo.getContentPane().add(month_end,new XYConstraints( 215, 35, 100, 20));
         inffo.getContentPane().add(year_end,new XYConstraints( 320, 35, 60, 20));
         month_start.setSelectedIndex(Integer.parseInt(curmonchar)-1);
         month_end.setSelectedIndex(Integer.parseInt(curmonchar)-1);
         year_start.setSelectedIndex(Integer.parseInt(curyearchar)-2003);
         year_end.setSelectedIndex(Integer.parseInt(curyearchar)-2003);
         inffo.getContentPane().add(sruli,new XYConstraints( 20, 70, 100, 20));
    buttons[OKindex].setRolloverEnabled(false);
    buttons[OKindex].setBorderPainted(true);
    buttons[CANCELindex].setRolloverEnabled(false);
    buttons[CANCELindex].setBorderPainted(true);
    inffo.getContentPane().add(buttons[OKindex], new XYConstraints( 40, sizeY-70, 50, 30));
    inffo.getContentPane().add(buttons[CANCELindex], new XYConstraints( sizeX-95, sizeY-70, 50, 30));
    inffo.show();
    inffo.hide();
    Thread.yield();
    if (isOK) {

.............queryes.........................
}
0
 
TimYatesCommented:
Have you tried using

 setVisible( false )

instead of hide() ?

Hide is a deprecated method :-/
0
 
kakoAuthor Commented:
no :(

I dont understand why I can't hide this jdialog
BEFORE processor-hungry query starts?
0
 
kakoAuthor Commented:
As I guess, I need something like this
suspend executing program and
"preccess windows messages"

but how do it in java?
0
 
CleanupPingCommented:
kako:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now