Panel components disappear when I minimize frame
java, jframe, jpanel, swing, user-interface
Solution
- for `JFrame` / `JDialog` / `JWindow`
to use
validate(); (revalidate in Java7 )
repaint();
example about standard rulles
use `CardLayout` instead of `remove` and then `add` the `JPanel` to the container
Problem
I have a layout with a main panel whose content is decided by me throught buttons in this way: ``` public void actionPerformed(ActionEvent e) { mainPanel.removeAll(); //removing all current panel components if(e.getActionCommand().equals("content1")){ mainPanel = new Content1Panel(); add(mainPanel,BorderLayout.CENTER); validate(); }else if(e.getActionCommand().equals("content2")){ mainPanel = new Content2Panel(); add(mainPanel,BorderLayout.CENTER); validate(); } } ``` now, if I minimize the frame and then bring it to front I find all main panel's components disappeared! Anyway, when I hover on them with the mouse components show again. What is wrong?