Hello.
I am running a program form my book and i get this warning from eclipse that says:
"The serializable class ColorWindow does not declare a static final serialVersionUID field of type long"
import javax.swing.*; //Needed for Swing classes
import java.awt.*; //Needed for COlor class
import java.awt.event.*;//Needed for event listener interface
/*
* This class demonstates how to set the background color of a
* panel and the foregorund color of a label
*/
public class ColorWindow extends JFrame{
/**
*
*/
private JLabel messageLabel; //To display a message
private JButton redButton; //changes color to red
private JButton blueButton; //changes color to blue
private JButton yellowButton; //change color to yellow
private JPanel panel; //a panel to build components
private final int WINDOW_WIDTH=200;//Window width
private final int WINDOW_HEIGHT=125;//Window hegith
/*
* Constructor
*/
public ColorWindow(){
//set the title bar text.
setTitle("Colors");
//set the size of the window
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
//Specify an action for the close button
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//create a label
messageLabel=new JLabel("Click a button to"+
"select a color");
//create the three buttons
redButton=new JButton ("Red");
blueButton=new JButton("Blue");
yellowButton=new JButton("Yellow");
//register an event listener with all three buttons
redButton.addActionListener(new RedButtonListener());
blueButton.addActionListener(new BlueButtonListener());
yellowButton.addActionListener(new YellowButtonListener());
//Create a panel and add the components to it
panel= new JPanel();
panel.add(messageLabel);
panel.add(redButton);
panel.add(blueButton);
panel.add(yellowButton);
//Add the panel to the content pane
add(panel);
//Dsiplay the window
setVisible(true);
}
/*
* Private inner class that handles the event
* when the user clicks the red button.
*/
private class RedButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
//set the panel's background to red
panel.setBackground(Color.RED);
//set the label's text to blue
messageLabel.setForeground(Color.BLUE);
}
}
/*
* Private inner class that handles the event when
* the user clicks the blue button
*/
private class BlueButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
//set the panel's background to blue
panel.setBackground(Color.BLUE);
//set the label's text to yellow
messageLabel.setForeground(Color.YELLOW);
}
}
/*
* Private inner class that handles the event when
* the user clicks the Yellow button
*/
private class YellowButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
//set the panel's background to yellow
panel.setBackground(Color.YELLOW);
//set the label's text to black
messageLabel.setForeground(Color.BLACK);
}
}
}
If anyone could help me?
Cheers-
haxtor