• Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane doesn't show  RSS feed

 
Chris Mattmiller
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The program gets to the JOptionPane part, reads it, then returns to the calling method without reading the rest of the recTrip method. If I comment the JOptionPane out the program runs through recTrip with no problems.
I put the JOptionPane in a try/catch hoping to catch an error but to no avail.

Here is the code:
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

What sort of class are you inside? I presume the "this" passed to the showConfirmDialog() method is an appropriate type.

What actually happens? Your thread title says "JOptionPane doesn't show," but I can't imagine that dialogue not showing unless there is a HeadlessException.
What are you doing with the result from the dialogue? It returns either JOptionPane.YES_OPTION or JOptionPane.NO_OPTION and you are supposed to test for those.I think you can also have CANCEL_OPTION as a return type: look here.

Can't see how that method would return without recording the ejbtm values. Try some System.out.println() statements in that method to show the old and new values.
 
G Estes
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the confirm dialog, you get (by default) Yes, No and Cancel buttons. You will need to query the returned value as follows and then take the appropriate action:


[ August 21, 2008: Message edited by: gil_e ]
 
Chris Mattmiller
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I modified the code a bit. Now instead of just leaving this method, it goes back to the "log.debug("setCurrentDriver begin again");" at the top. Comment out the JOptionPane and it will run the program as expected.

I copied the JOptionPane from another method and only changed the message.

 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wherever you copied it from, they might have a mistake there too
I presume you actually see the option pane dialogue window?
Suggest you insert a System.out.println() statement after "if (result == JOptionPane.YES_OPTION) {"
and before "log.info(. . ." to tell you where you have gone (or even
"JOptionPane.showMessageDialog(this, "In Yes block", "OK");").
Similar print or showMessageDialog statements will let you follow the execution through the whole method.

Or you can use the debugging function of an IDE.
[ August 21, 2008: Message edited by: Campbell Ritchie ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!