I have JFrame, which contain JInternalFrame. JInternalFrame contains 3 labels, 3 textfield and 2 buton.
When user after entering details in textfield click OK, if any of the textfield is left blank a message is displayed and focus should return to that textfield.
When JOptionPane.showMessageDialog is used it works perfect, it display message and focus return to empty textfield.
The problem is when using JOptionPane.showInternalMessageDialog it display message and focus remain on OK button.
Please help and let me know what i am missing in the code.
Yes it true, but there is two thing.
First : look of message dialog using showMessageDialog and showInternalMessageDialog is different.
Second : I want to know why its not working. I tried but cant figure out the problem, so i posted the same here to get help.
1) looks like showInternalMessageDialog inherits the L & F of its parent.
it needs a parent (try null as parent) whereas the showMessageDialog doesn't.
2) you'd need to dig into the source codes of both to see what's different.
simple fix is to add the earlier line
Message = ValidateForm();
after the optionPane. having it the second time will only handle the focus request.
1) looks like showInternalMessageDialog inherits the L & F of its parent.
it needs a parent (try null as parent) whereas the showMessageDialog doesn't.
It show Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent
2) you'd need to dig into the source codes of both to see what's different.
simple fix is to add the earlier line
Message = ValidateForm();
after the optionPane. having it the second time will only handle the focus request.
It works that ways and already tried before posting code for help.
It will not be good programming to call the routine twice for focus, but for temporary solution i will go with it until I find any solution.