Solved

Problem with JOptionPane

Posted on 2004-09-11
5
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

696 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