Hi can someone help me disappear the button on click..... i have the windowDestroyer and the driver class
mport javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
Simple demonstration of putting buttons in a JFrame.
*/
public class ButtonDemo extends JFrame implements ActionListener
{
public static final int WIDTH = 400;
public static final int HEIGHT = 300;
public ButtonDemo( )
{
setSize(WIDTH, HEIGHT);
WindowDestroyer listener = new WindowDestroyer( );
addWindowListener(listener);
Container contentPane = getContentPane( );
contentPane.setBackground(Color.WHITE);
contentPane.setLayout(new FlowLayout( ));
JButton sunnyButton = new JButton("Sunny");
sunnyButton.addActionListener(this);
contentPane.add(sunnyButton);
sunnyButton.setVisible(false);
JButton cloudyButton = new JButton("Cloudy");
cloudyButton.addActionListener(this);
contentPane.add(cloudyButton);
}
public void actionPerformed(ActionEvent e)
{
String actionCommand = e.getActionCommand( );
Container contentPane = getContentPane( );
JButton sunnyButton = new JButton("Sunny");
JButton cloudyButton = new JButton("Cloudy");
if (actionCommand.equals("Sunny"))
contentPane.setBackground(Color.BLUE);
sunnyButton.setVisible(false);/*SHOULDN'T THIS METHOD MAKE BUTTON DISAPPEAR BUT IT DOESN'T WORK!!!! HELP PLZ*/
else if (actionCommand.equals("Cloudy"))
contentPane.setBackground(Color.GRAY);
else
System.out.println("Error in button interface.");
}