MianBaoBread
面包bread
采纳率100%
2020-09-12 06:25 阅读 194
已采纳

问题The serializable class PaintFrame does not declare a static final serialVersionUID field of type long

工具为vscode,尝试创建一个居中的窗口时显示一个问题

The serializable class PaintFrame does not declare a static final serialVersionUID field of type long Java(536871008) [6, 14]

上网查了一下,都说是Eclipse的问题,但我用的是vscode,所以比较懵圈

import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JFrame;

public class PaintFrame extends JFrame{

    public static void main(String[] args) {
        new PaintFrame();
    }

    public PaintFrame() {
        int windowWidth = 1600;
        int windowHeight = 900;

        Dimension d = new Toolkit.getDefaultToolkit().getScreenSize();
        int screenWidth = d.width;
        int screenHeight = d.height;

        setTitle("画板");
        setSize(windowWidth, windowHeight);
        setResizable(false);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocation((screenWidth - windowWidth) / 2, (screenHeight - windowHeight) / 2);
    }
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    hjs218 Json-Huang 2020-09-12 09:32

    根据提示可先在public static void main前加上类似如下代码

     private static final long serialVersionUID = -3206065828593806732L;
    
    点赞 评论 复制链接分享

相关推荐