I currently am using a JOptionPane
to pop up a message and display it to the user. The message is not always on top of other windows so I put it in a dummy JFrame
(errorFrame
) and set errorFrame
to always be on top. This works for keeping the errorFrame
always on top, but it creates a second, empty frame in the upper right of the screen. The option pane appears at 100,100 just like I am setting the location of the dummy frame which contains it. Why is this second frame being created? All help is appreciated
UPDATE: I got the idea to put the JOptionPane
inside of a JFrame
from this post:
JOptionPane won't show its dialog on top of other windows
try {
JFrame errorFrame = new JFrame();
errorFrame.setVisible(true);
errorFrame.setAlwaysOnTop(true);
if (true) {
JOptionPane.showMessageDialog(errorFrame,
"blah blah",
"blahblahblah",
JOptionPane.WARNING_MESSAGE);
return true;
}
errorFrame.dispose();
}