Closed. This question needs debugging details。它当前不接受答案。
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
4年前关闭。
我在Eclipse中遇到此错误。有什么想法吗?
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
4年前关闭。
我在Eclipse中遇到此错误。有什么想法吗?
import java.awt.*;
import javax.swing.*;
public class Main {
JFrame frame;
frame.setTitle("Elevator build 11");
frame.setPositionRelativeTo(null);
frame.setVisible(true);
}
最佳答案
您的代码必须在方法内部。尝试将其放入主要方法中。另外,您需要首先实例化框架。
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame(); //instantiate frame
// set the title
// set the position
// set it visible
}
}