public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if(e.getSource() == panel1.button1){ removeAll(); add(mainmenu1); validate(); repaint(); } if(e.getSource() == mainmenu1.button1){ removeAll(); add(panel1); validate(); repaint(); } }