window Destroyer
what does window destroyer do? i removed it from a code but i didn't notice the difference...the reason i removed it was because it said cannot resolve symbol class Window destroyer so i just added "//" to make it a comment and the program seemed to work just fine...
-od
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
publicclass ButtonDemoextends JFrameimplements ActionListener
{
publicstaticfinalint WIDTH= 300;
publicstaticfinalint HEIGHT= 200;
publicstaticvoid main(String[] args)
{
ButtonDemo buttonGui=new ButtonDemo();
buttonGui.setVisible(true);
}
public ButtonDemo()
{
setSize(WIDTH, HEIGHT);
//addWindowListener(new WindowDestroyer());
setTitle("Button Demo");
Container contentPane= getContentPane();
contentPane.setBackground(Color.BLUE);
contentPane.setLayout(new FlowLayout());
JButton stopButton=new JButton("Red");
stopButton.addActionListener(this);
contentPane.add(stopButton);
JButton goButton=new JButton("Green");
goButton.addActionListener(this);
contentPane.add(goButton);
}
publicvoid actionPerformed(ActionEvent e)
{
Container contentPane= getContentPane();
if (e.getActionCommand().equals("Red"))
contentPane.setBackground(Color.RED);
elseif (e.getActionCommand().equals("Green"))
contentPane.setBackground(Color.GREEN);
else
System.out.println("Error in button interface");
}
}

