高手帮我看看这个JAVA程序哪里错了
importjava.awt.*;classMyFrameextendsFrame{privatePanelBorderPanel;privatePanelFlowPan...
import java.awt.*;
class MyFrame extends Frame
{
private Panel BorderPanel;
private Panel FlowPanel;
private Panel GridPanel;
private Panel CardPanel;
public MyFrame(String title)
{
super(title);
setSize(600,400);
setLocation(100,100);
setBorderPanel();
setFlowPanel();
setGridPanel();
setCardPanel();
setLayout(new GridLayout(2,2));
add(BorderPanel);
add(FlowPanel);
add(GridPanel);
add(CardPanel);
}
public void setBorderPanel()
{
Panel BorderPanel=new Panel();
Button b1=new Button("东");
Button b2=new Button("西");
Button b3=new Button("南");
Button b4=new Button("北");
Button b5=new Button("中");
BorderPanel.setLayout(new BorderLayout());
BorderPanel.add(b1,BorderLayout.EAST);
BorderPanel.add(b2,BorderLayout.WEST);
BorderPanel.add(b3,BorderLayout.SOUTH);
BorderPanel.add(b4,BorderLayout.NORTH);
BorderPanel.add(b5,BorderLayout.CENTER);
}
public void setFlowPanel()
{
Panel FlowPanel=new Panel();
Button b1=new Button("AAA");
Button b2=new Button("BBB");
FlowPanel.setLayout(new FlowLayout()); FlowPanel.add(b1);
FlowPanel.add(b2);
}
public void setGridPanel()
{
Panel GridPanel=new Panel();
Button b1=new Button("A");
Button b2=new Button("B");
Button b3=new Button("C");
Button b4=new Button("D");
Button b5=new Button("E");
Button b6=new Button("F");
GridPanel.setLayout(new GridLayout(2,3));
GridPanel.add(b1);
GridPanel.add(b2);
GridPanel.add(b3);
GridPanel.add(b4);
GridPanel.add(b5);
GridPanel.add(b6);
}
public void setCardPanel()
{
Panel CardPanel=new Panel();
Button b1=new Button("A");
Button b2=new Button("B");
CardPanel.setLayout(new CardLayout());
CardPanel.add(b1,"1");
CardPanel.add(b2,"2");
}
public static void main(String args[])
{
MyFrame f=new MyFrame("布局管理器");
f.show();
}
} 展开
class MyFrame extends Frame
{
private Panel BorderPanel;
private Panel FlowPanel;
private Panel GridPanel;
private Panel CardPanel;
public MyFrame(String title)
{
super(title);
setSize(600,400);
setLocation(100,100);
setBorderPanel();
setFlowPanel();
setGridPanel();
setCardPanel();
setLayout(new GridLayout(2,2));
add(BorderPanel);
add(FlowPanel);
add(GridPanel);
add(CardPanel);
}
public void setBorderPanel()
{
Panel BorderPanel=new Panel();
Button b1=new Button("东");
Button b2=new Button("西");
Button b3=new Button("南");
Button b4=new Button("北");
Button b5=new Button("中");
BorderPanel.setLayout(new BorderLayout());
BorderPanel.add(b1,BorderLayout.EAST);
BorderPanel.add(b2,BorderLayout.WEST);
BorderPanel.add(b3,BorderLayout.SOUTH);
BorderPanel.add(b4,BorderLayout.NORTH);
BorderPanel.add(b5,BorderLayout.CENTER);
}
public void setFlowPanel()
{
Panel FlowPanel=new Panel();
Button b1=new Button("AAA");
Button b2=new Button("BBB");
FlowPanel.setLayout(new FlowLayout()); FlowPanel.add(b1);
FlowPanel.add(b2);
}
public void setGridPanel()
{
Panel GridPanel=new Panel();
Button b1=new Button("A");
Button b2=new Button("B");
Button b3=new Button("C");
Button b4=new Button("D");
Button b5=new Button("E");
Button b6=new Button("F");
GridPanel.setLayout(new GridLayout(2,3));
GridPanel.add(b1);
GridPanel.add(b2);
GridPanel.add(b3);
GridPanel.add(b4);
GridPanel.add(b5);
GridPanel.add(b6);
}
public void setCardPanel()
{
Panel CardPanel=new Panel();
Button b1=new Button("A");
Button b2=new Button("B");
CardPanel.setLayout(new CardLayout());
CardPanel.add(b1,"1");
CardPanel.add(b2,"2");
}
public static void main(String args[])
{
MyFrame f=new MyFrame("布局管理器");
f.show();
}
} 展开
展开全部
import java.awt.*;
class MyFrame extends Frame {
private Panel BorderPanel;
private Panel FlowPanel;
private Panel GridPanel;
private Panel CardPanel;
public MyFrame(String title) {
super(title);
setSize(600, 400);
setLocation(100, 100);
setBorderPanel();
setFlowPanel();
setGridPanel();
setCardPanel();
setLayout(new GridLayout(2, 2));
add(BorderPanel);
add(FlowPanel);
add(GridPanel);
add(CardPanel);
}
public void setBorderPanel() {
BorderPanel = new Panel();//去掉定义
Button b1 = new Button("东");
Button b2 = new Button("西");
Button b3 = new Button("南");
Button b4 = new Button("北");
Button b5 = new Button("中");
BorderPanel.setLayout(new BorderLayout());
BorderPanel.add(b1, BorderLayout.EAST);
BorderPanel.add(b2, BorderLayout.WEST);
BorderPanel.add(b3, BorderLayout.SOUTH);
BorderPanel.add(b4, BorderLayout.NORTH);
BorderPanel.add(b5, BorderLayout.CENTER);
}
public void setFlowPanel() {
FlowPanel = new Panel();//去掉定义
Button b1 = new Button("AAA");
Button b2 = new Button("BBB");
FlowPanel.setLayout(new FlowLayout());
FlowPanel.add(b1);
FlowPanel.add(b2);
}
public void setGridPanel() {
GridPanel = new Panel();//去掉定义
Button b1 = new Button("A");
Button b2 = new Button("B");
Button b3 = new Button("C");
Button b4 = new Button("D");
Button b5 = new Button("E");
Button b6 = new Button("F");
GridPanel.setLayout(new GridLayout(2, 3));
GridPanel.add(b1);
GridPanel.add(b2);
GridPanel.add(b3);
GridPanel.add(b4);
GridPanel.add(b5);
GridPanel.add(b6);
}
public void setCardPanel() {
CardPanel = new Panel(); //去掉定义
Button b1 = new Button("A");
Button b2 = new Button("B");
CardPanel.setLayout(new CardLayout());
CardPanel.add(b1, "1");
CardPanel.add(b2, "2");
}
public static void main(String args[]) {
MyFrame f = new MyFrame("布局管理器");
f.show();
}
}
//开始定义对象不要再方法中再定义了
class MyFrame extends Frame {
private Panel BorderPanel;
private Panel FlowPanel;
private Panel GridPanel;
private Panel CardPanel;
public MyFrame(String title) {
super(title);
setSize(600, 400);
setLocation(100, 100);
setBorderPanel();
setFlowPanel();
setGridPanel();
setCardPanel();
setLayout(new GridLayout(2, 2));
add(BorderPanel);
add(FlowPanel);
add(GridPanel);
add(CardPanel);
}
public void setBorderPanel() {
BorderPanel = new Panel();//去掉定义
Button b1 = new Button("东");
Button b2 = new Button("西");
Button b3 = new Button("南");
Button b4 = new Button("北");
Button b5 = new Button("中");
BorderPanel.setLayout(new BorderLayout());
BorderPanel.add(b1, BorderLayout.EAST);
BorderPanel.add(b2, BorderLayout.WEST);
BorderPanel.add(b3, BorderLayout.SOUTH);
BorderPanel.add(b4, BorderLayout.NORTH);
BorderPanel.add(b5, BorderLayout.CENTER);
}
public void setFlowPanel() {
FlowPanel = new Panel();//去掉定义
Button b1 = new Button("AAA");
Button b2 = new Button("BBB");
FlowPanel.setLayout(new FlowLayout());
FlowPanel.add(b1);
FlowPanel.add(b2);
}
public void setGridPanel() {
GridPanel = new Panel();//去掉定义
Button b1 = new Button("A");
Button b2 = new Button("B");
Button b3 = new Button("C");
Button b4 = new Button("D");
Button b5 = new Button("E");
Button b6 = new Button("F");
GridPanel.setLayout(new GridLayout(2, 3));
GridPanel.add(b1);
GridPanel.add(b2);
GridPanel.add(b3);
GridPanel.add(b4);
GridPanel.add(b5);
GridPanel.add(b6);
}
public void setCardPanel() {
CardPanel = new Panel(); //去掉定义
Button b1 = new Button("A");
Button b2 = new Button("B");
CardPanel.setLayout(new CardLayout());
CardPanel.add(b1, "1");
CardPanel.add(b2, "2");
}
public static void main(String args[]) {
MyFrame f = new MyFrame("布局管理器");
f.show();
}
}
//开始定义对象不要再方法中再定义了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询