I have just started on AWT and made a simple program in it, it works fine but it shows a warning message in eclipse which i don't understand:
The serializable class TestGUI does not declare a static final serialVersionUID field of type long
I know that the warning message is not related to AWT and there was no need to post my whole code but when i tried to make a SSCCE of the code the warning also disappeared. Since I don't know why this warning is generated i didn't knew which part to retain in my SSCCE. Hence the whole code!
My code is:
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class TestGUI extends Frame {
/**
* @param args
*/
private int x = 50;
private int y = 50;
TestGUI(String s) {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
setVisible(false);
System.exit(0);
}
});
addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent me) {
x = me.getX();
y = me.getY();
repaint();
}
});
}
public void paint(Graphics g) {
g.drawString("Hello Princess", 100, 100);
g.drawString("Mouse clicked here", x, y);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
TestGUI tg = new TestGUI("first");
tg.setSize(500, 500);
tg.setVisible(true);
}
}
Thanx in advance!