报错:Exception in thread "main" java.lang.Error: Unresolved compilation problem: 求指导啊。
importjava.awt.*;importjavax.swing.*;publicclassBorderJButtonextendsJFrame{publicBord...
import java.awt.*;import javax.swing.*;
public class BorderJButton extends JFrame{
public BorderJButto{ //Syntax error on token "public",
// class expected after this token
add(new Button("North"),BorderLayout.NORTH);
add(new Button("South"),BorderLayout.SOUTH);
add(new Button("East"),BorderLayout.EAST);
add(new Button("West"),BorderLayout.WEST);
add(new Button("Center"),BorderLayout.CENTER);
}
public static void main(String[] args){
BorderJButton frame=new BorderJButton();
frame.setTitle("测试BorderLayout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 150);
frame.setVisible(true);
}
} 展开
public class BorderJButton extends JFrame{
public BorderJButto{ //Syntax error on token "public",
// class expected after this token
add(new Button("North"),BorderLayout.NORTH);
add(new Button("South"),BorderLayout.SOUTH);
add(new Button("East"),BorderLayout.EAST);
add(new Button("West"),BorderLayout.WEST);
add(new Button("Center"),BorderLayout.CENTER);
}
public static void main(String[] args){
BorderJButton frame=new BorderJButton();
frame.setTitle("测试BorderLayout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 150);
frame.setVisible(true);
}
} 展开
展开全部
你这个构造方法连括号都没有 编译肯定会有问题 发出来的方法名也不对
public BorderJButton()
{
}
public BorderJButton()
{
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
改成这样:
import java.awt.*;
import javax.swing.*;
public class BorderJButton extends JFrame {
public BorderJButton() {
// Syntax error on token "public",
// class expected after this token
add(new Button("North"), BorderLayout.NORTH);
add(new Button("South"), BorderLayout.SOUTH);
add(new Button("East"), BorderLayout.EAST);
add(new Button("West"), BorderLayout.WEST);
add(new Button("Center"), BorderLayout.CENTER);
}
public static void main(String[] args) {
BorderJButton frame = new BorderJButton();
frame.setTitle("测试BorderLayout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 150);
frame.setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
public class BorderJButton extends JFrame {
public BorderJButton() {
// Syntax error on token "public",
// class expected after this token
add(new Button("North"), BorderLayout.NORTH);
add(new Button("South"), BorderLayout.SOUTH);
add(new Button("East"), BorderLayout.EAST);
add(new Button("West"), BorderLayout.WEST);
add(new Button("Center"), BorderLayout.CENTER);
}
public static void main(String[] args) {
BorderJButton frame = new BorderJButton();
frame.setTitle("测试BorderLayout");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 150);
frame.setVisible(true);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
构造方法没括号,名字末尾也差个n
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询