Solved

Problem with JOptionPane

Posted on 2004-09-11
5
217 Views
Last Modified: 2010-03-31
I have a command:

   int ret = JOptionPane.showConfirmDialog(this, "Each neural network will have over " + NeuralNet.warningSize() + " connections.\n"
                                                        + "Would you like to continue?", "Confirm Network Size", JOptionPane.YES_NO_OPTION);
                                                       
            if (ret == JOptionPane.NO_OPTION) return null;
       
which is run in a seperate thread.  I cannot click on the yes or no options, although I can click on the X or hit enter and tab and it works properly.  Why does the mouse not work on the buttons?
0
Comment
Question by:jjacksn
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 12033888
try using EventQueue.invokeLater() to run the dialog on the event dispatch thread.
0
 
LVL 8

Expert Comment

by:pjcrooks2000
ID: 12034000
If objects says it then thats the answer ;)  you could tie in other mouse listeners to the buttons but they should be tied into the event dispatch thread not your own thread as the man himself has said above, I am not arguing with the man OBJ live on..........

Good luck to you!

pjcrooks2000
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 12038207
>> which is run in a seperate thread.

Could you show the full-code where you do this?

I think that you're unknowingly displaying the same JOptionPane again on click of the Yes or No buttons.
0
 
LVL 5

Expert Comment

by:Naeemg
ID: 12110074
your code works properly, can u explain ur problem in more details?
or show ur code where u use it?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 12357532
jjacksn, you should be a little more interactive with experts who try to help you on your page, and at least answer a few questions if they ask them in the process. Anyway, the answer you accepted seems to be right :)
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ArrayIndexOutOfBoundException 9 81
diffSum example 4 37
pagenation logic how it is working in my code 1 30
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 33
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question