I have a problem where I create two separate JFrame
s (one is my main application, the other shows task progress using console output...).
However, subsequently bringing up a dialog box has a strange effect on the two taskbar icons (i.e. for the JFrame
s). Namely it causes one taskbar icon to disappear, although both windows still exist. Note that the missing taskbar icon can be "restored" by minimising or maximising the corresponding window.
The following example code generates the problem:
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class taskbarExample {
private static JFrame frame1;
private static JFrame frame2;
public static void main (String[] args) {
frame1 = new JFrame("Frame 1");
frame1.setSize(200,600);
frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame1.setVisible(true);
frame2 = new JFrame("Frame 2");
frame2.setSize(600,200);
frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame2.setVisible(true);
JOptionPane.showMessageDialog(null, "Dialog box");
}
}
For comparison, try commenting out the JOptionPane
line... results in no problems.
Can anyone explain what is going on here? I have seen a previous question referring to a similar problem, but without example code and no answer that helped me. Found here