acabo de empezar a trabajar en AWT e hizo un programa simple en él, funciona bien pero muestra un mensaje de advertencia en Eclipse, que no entiendo:advertencia campo serialVersionUID en Eclipse
El TestGUI clase serializable no declara un campo serialVersionUID static final de tipo long
yo sé que el mensaje de aviso no está relacionado con AWT y no había necesidad de publicar toda mi código, pero cuando he intentado hacer una SSCCE del código la advertencia también desapareció. Como no sé por qué se genera esta advertencia, no sabía qué parte retener en mi SSCCE. De ahí el código completo!
Mi código es:
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);
}
}
Gracias de antemano!
posible duplicado de [¿Qué es un serialVersionUID y por qué debería usarlo?] (Http://stackoverflow.com/questions/285793/what-is-a-serialversionuid-and-why-should-i-use- it) –