我在serialVersionUID 的行中有一个语法错误。为了解决这个错误,我必须在该行的末尾放置一个括号并在我的代码末尾关闭它......我的问题是为什么?在包含 Jframe 的文件中不需要这个......还有什么是 serialVersionUID?如果我的问题看起来很初级,我很抱歉,我是编程新手,Java 新手,这是我在 GUI 上的第 3 天。
import javax.swing.*;
public class HangmanPanel extends JPanel{
private static final long serialVersionUID = -1767262708330188227L;{
this.setLayout(null);
JLabel heading = new JLabel("Welcome to the Hangman App");
JButton Button = new JButton("Ok");
//get input
JLabel tfLable = new JLabel("Please Enter a Letter:");
JTextField text = new JTextField(10);
heading.setSize(200, 50);
tfLable.setSize(150, 50);
text.setSize(50, 30);
Button.setSize(60, 20);
heading.setLocation(300, 10);
tfLable.setLocation(50, 40);
text.setLocation(50, 80);
Button.setLocation(100, 85);
this.add(heading);
this.add(tfLable);
this.add(text);
this.add(Button);
}}