I have a middlePanel that displays panel1 with 6 button in it. On clicking a button, other components are displayed in mainPanel and finally returning back to panel1.
The problem I face here is : the components aren't shown at once - I got go move cursor around to make it visible. The code I use to set the panels is :
public void SetMainPanel(JPanel panel) {
middlePanel.removeAll();
this.middlePanel = panel;
panel.setVisible(true);
this.middlePanel.setVisible(true);
mainPanel.add(middlePanel, BorderLayout.CENTER);
middlePanel.revalidate();
middlePanel.repaint();
mainPanel.revalidate();
mainPanel.repaint();
}
See am set visible to the passed panel, and middlePanel in which it is added. updateui & validate middlePanel and mainPanel that contains middlePanel. Yet why is this problem.
Can anyone help me know why is this problem and how o solve it. I feel their is a way to get rid of this problem but couldn't recall it.