Solved

Problem with JOptionPane

Posted on 2004-09-11
5
198 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:mayankeagle
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:mayankeagle
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now