public class Frame { private JFrame jFrame = new JFrame("<test> BattleSea </test>"); public FieldComp fieldComp = new FieldComp(); public FieldPlayer fieldPlayer = new FieldPlayer(); private MidPaneStart midPaneStart = new MidPaneStart(); private MidPaneGame midPaneGame = new MidPaneGame(); private ImageIcon imageComp = new ImageIcon("comp.png"); private ImageIcon imagePlayer = new ImageIcon("player.png"); private ImageIcon imageStart = new ImageIcon("startP.png"); public Frame(){ jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); jFrame.setMinimumSize(new Dimension(1100,485)); jFrame.setLocation(350,200); jFrame.getContentPane().setLayout(new BorderLayout()); jFrame.setResizable(false); jFrame.getContentPane().add(fieldComp.getPane(),BorderLayout.EAST); jFrame.getContentPane().add(fieldPlayer.getPane(),BorderLayout.WEST); jFrame.pack(); jFrame.setVisible(true); int i = (int)(Math.random()*2+1); setHod(i); midPaneStart.getTablo().setIcon(imageStart); setMidPane("2"); } public void setHod(int i){ if (i == 1) { midPaneGame.getTablo().setIcon(imageComp); } else { midPaneGame.getTablo().setIcon(imagePlayer); } } public void setMidPane(String w){ switch (w){ case "1": System.out.println(1); jFrame.getContentPane().add(midPaneStart.getMidPaneStart(),BorderLayout.CENTER); break; case "2": System.out.println(2); jFrame.getContentPane().add(midPaneGame.getMidPaneGame(),BorderLayout.CENTER); break; case "3": jFrame.getContentPane().remove(2); break; default: break; } } } At the press of a button you need to change the panels, but they do not change. If you click on the Remove button - the panel simply stops responding. From other classes I call the method via static instant in main . There is a response, i.e. sockets change (delete) when you stretch the window, and as if freezes.