• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JOptionPane doesn't show

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Marshal
Posts: 80124
416
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 80124
416
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
I'm doing laundry! Look how clean this tiny ad is:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic