It's not a good idea, to do what you want, but I have a solution. You can simply disable all key events when dialog shown. Here is a sample.
AWTEventListener myListener = new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
if (event instanceof KeyEvent) {
((KeyEvent) event).consume();
}
}
};
Toolkit.getDefaultToolkit().addAWTEventListener(myListener, AWTEvent.KEY_EVENT_MASK);
JOptionPane.showMessageDialog(null, "You have a message!");
Toolkit.getDefaultToolkit().removeAWTEventListener(myListener);
Please use this solution only if your boss really want it. I would preffer to make your text component non-editable and show the warning message as ovelay to it (you can use JLayeredPane for this purpose).