Swing variant and jdk version version

I have a combo box. After selecting an item in the combo box, a new JDialog opens.

  • When I use JDK 1.6_06, I can click the buttons in JDialog properly.
  • When I use JDK 1.6_24, then I need to click anywhere First JDialog. Then press the button works. At first I thought it was a focus problem. But the component works fine with JDK 1.6_06. But this is only a problem with JDK 1.6_24.

I tried to do this. But did not find the answer. Somebody knows?

+7
source share
2 answers

@ All: Aplogize for a late reply. I tested different scenarios. And I found that the problem is with streaming processing. It seems that the combo box has not finished its work, and jdialog is opening. And after that, the combo box tries to complete its work, so the focus is lost in the parent window. I tried to open a dialog in a thread:

new Thread() { public void run() { // open dialog here } }.start(); 

And it works great. Now I plan to open a dialog using SwingWorker:

  SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { // TODO Auto-generated method stub // open dialog here return null; } }; 

This also works. Hope this is the right way. Please let me know if I am doing the right thing.

0
source

I do not know about java versions, but in the SwingUtilities # true dialog box invisible (true) called invokeLater to solve this problem some time ago. YMMV.

+1
source

All Articles