setLayout(new BorderLayout());报错,一下是代码,在myeclipse中运行
importjava.applet.Applet;importjava.awt.*;publicclassBorderLayoutextendsApplet{privat...
import java.applet.Applet;
import java.awt.*;
public class BorderLayout extends Applet {
private Button centerButton, eastButton, northButton, westButton, southButton;
public void init(){
setLayout(new BorderLayout());
centerButton = new Button("center Button");
westButton = new Button("west Button");
eastButton = new Button("east Button");
southButton = new Button("south Button");
northButton = new Button("north Button");
add("South", southButton);
add("North", northButton);
add("East", eastButton);
add("West", westButton);
add("Center", centerButton);
}
}
结果java.lang.ClassCastException: dy0415.BorderLayout
at dy0415.BorderLayout.init(BorderLayout.java:10)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source) 展开
import java.awt.*;
public class BorderLayout extends Applet {
private Button centerButton, eastButton, northButton, westButton, southButton;
public void init(){
setLayout(new BorderLayout());
centerButton = new Button("center Button");
westButton = new Button("west Button");
eastButton = new Button("east Button");
southButton = new Button("south Button");
northButton = new Button("north Button");
add("South", southButton);
add("North", northButton);
add("East", eastButton);
add("West", westButton);
add("Center", centerButton);
}
}
结果java.lang.ClassCastException: dy0415.BorderLayout
at dy0415.BorderLayout.init(BorderLayout.java:10)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询