My class Output.java
extends JPanel
. From another class, the user can click on an icon and then it locally creates a JFrame
with the Output.java
. We found that sometimes the user minimizes that window and then will want it back. He will then reclick on the icon and the JFrame
is recreated. By doing it a few times, the Output.java
class is displayed several times.
I've found that it is possible to disable multiple JFrame
creation by adding this:
if (!output.isShowing())
openPage(output);
But it doesn't restore the JFrame
. Is there a way to restore a minimized JFrame
in this situation?
icon.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
openPage(outputsSlavePane);
}
});
private void openPage(final Output panel) {
JFrame frame = new JFrame("Output");
frame.add(panel);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
panel.setLostFocus();
}
});
}
Thanks.