我正在尝试制作一个简单的 java 2-d 平台游戏。Java一直给我带来一些错误“可序列化类Display没有声明long类型的静态最终serialVersionUID字段”有人可以帮忙吗?
这是我尝试运行程序时收到的错误消息:http: //i.imgur.com/H0Afv.png (在网站上)
这是代码:
import javax.swing.*;
public class Main {
public static Display f;
public static int width = 800;
public static int height = 600;
public static void main(String[] args)
{
f = new Display();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setResizable(true);
f.setSize(width, height);
f.setLocationRelativeTo(null);
f.setTitle("2-D Platformer");
}
}
//This is my display class.
import java.awt.*;
import javax.swing.*;
/* this is where the error is
*
*/ V
public class Display extends JFrame{
public Display p;
public Display()
{
p = new Display();
add(p);
setLayout(new GridLayout(1, 1, 0 , 0));
}
}
//and this is my display2 class
import java.awt.Color;
import javax.swing.*;
/* this is where the error is
*too
*/ V
public class Display2 extends JPanel{
public Display2()
{
setBackground(Color.BLACK);
}
}