I've got a problem. I need something more sophisticated than JOptionPane.show*Dialog(), so I've decided to subclass the JDialog.
I was adding some action JButtons (confirm / cancel) but then I realized what the problem is.
When I'll add the JButtons just with add() i will get the exact order of the buttons as inserted. So will end with CONFIRM CANCEL button in that order. However, when I use the System-dependent look and feel, the order of the buttons could be different.
For example, when I create the dialog with JOptionPane.show*Dialog() it always create the buttons adequate to the actual L&F, so in default one I will have
| CONFIRM CANCEL |
Why not use JOptionPane's own dialog? In its Javadoc there is an example titled "Direct Use". You simply call the createDialog method, do some things to that dialog, then call setVisible(true) (not show()!).
Yes, the JOptionPane.createDialog(-) is a solution, but I would like to do some validation before the dialog closes. For example - if data input by the user is not a number, popup an alert and let the user fix it.
Joined: Jun 13, 2009
but I would like to do some validation before the dialog closes