how would i get my program to work so that when a button is clicked it is removed?
here is the code:
//Mainmenu
JFrame frame1 = new JFrame();
Container pane = frame1.getContentPane();
JButton a = new JButton(new ImageIcon("path2img"));
BufferedImage a1 = ImageIO.read(new File("path2img"));
public Menu() throws IOException {
frame1.setSize(300, 450);
frame1.setLocationRelativeTo(null);
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame1.setResizable(false);
frame1.setVisible(true);
pane.add(a);
a.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent aa) {
pane.remove(a);
}
});
}
thanks