Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes intercepting return from JOptionPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "intercepting return from JOptionPane" Watch "intercepting return from JOptionPane" New topic
Author

intercepting return from JOptionPane

Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Hi all!
I'm using a JList in a JOptionPane to get some input from the user. When I call JOptionPane.showOptionDialog(), it will return an int indicating the result (i.e., whether the user clicked OK or CANCEL, etc.).
My question is, I would like to be able to check the user input BEFORE the JOptionPane disappears. For example, if the user clicked the OK button but did NOT select an item from the JList, I would like to use a beep to alert them and keep the JOptionPane up until the user either selects a value or clicks CANCEL.
Does anyone know a way to achieve this?
Thanks!
Stephanie
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Sounds like a situation that requires a custom dialog. JOptionPane is great for generic functionality in message boxes, but if you have to do any custom handling, you will probably have to create a custom dialog box to do it.
Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Thanks, Bodie!
I'll look into that.
Stephanie
 
GeeCON Prague 2014
 
subject: intercepting return from JOptionPane