JPanel panel = new JPanel(); JButton button1 = new JButton("Button 1"); JButton button2 = new JButton("Button 2"); panel.add(button1); panel.add(button2); panel.remove(button1); // Remove button1 from panelThis code creates a JPanel, adds two buttons to it, and then removes one of the buttons. Package/Library: javax.swing.JPanel is a class in the Java Swing library.