• Post Reply Bookmark Topic Watch Topic
  • New Topic

having trouble with JOptionPane  RSS feed

 
mike mcstar
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am experimenting with messages in JOptionPane and I was wondering why this program does not display anything when the choices are inputted.
*note: I tried putting "JOptionPane.showMessageDialog(null, "This is an information message", "Information", JOptionPane.INFORMATION_MESSAGE);" after the "int i = 0;" and then the messages displayed.
Could someone please explain this to me? Thanks!

 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your program works for me. Are the JOptionPanes not appearing for you?
 
mike mcstar
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it doesn't work for me. It compiles but when options are selected no JOptionPanes appear.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "options are selected", exactly how did they get selected?
 
mike mcstar
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the user input. For example, the user enters "1" and then the information message should appear.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And when the user "enters" 1, does the user press the "1" key and then the "Enter" key?
 
mike mcstar
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Your code worked nicely when I tried it.
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Running this code from within NetBeans, I do not get these JOptionPanes too.

However, if I add just one line, like this:

then it works as it should.

Now, I must admit I have no idea what's going on, why adding this one line
get things working. Something about the EDT that isn't initialized?

Greetz,
Piet
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try running the code unchanged in NetBeans, entering a number, waiting 1″, and minimising NetBeans
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I guess I wasn't initialized...

But why adding this one line puts theses panes to the foreground...???
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muiski???
I would be interested to know what happens when you minimise NetBeans.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!