我知道这个主题已经被破坏了几次,但是当我按照据说在其他主题中修复的方式修复它时遇到了错误。
public static class FlowAp extends JFrame{
String one = "One";
String two = "Two";
String three = "Three";
String four = "Four";
String five = "Five";
public static void main(String argv[]){
FlowAp fa=new FlowAp();
//Change from BorderLayout default
fa.getContentPane().setLayout(new FlowLayout());
fa.setSize(200,200);
fa.setVisible(true);
}
FlowAp(){
JButton one = new JButton("One");
getContentPane().add(one);
JButton two = new JButton("Two");
getContentPane().add(two);
JButton three = new JButton("Three");
getContentPane().add(three);
JButton four = new JButton("four");
getContentPane().add(four);
JButton five = new JButton("five");
getContentPane().add(five);
}
}
当我实际上在它们看起来应该出现的地方放入括号时,flowap 出现了另一个错误。“无效的方法声明”
最佳答案
尝试删除“静态”:
public class FlowAp extends JFrame{
关于Java-在类中找不到 Main 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7649820/