java 里的GridLayout试了试就是有错,求解(代码) 5
importjava.awt.*;importjavax.*;importjava.awt.LayoutManager;publicclassGridLayout{pub...
import java.awt.*;
import javax.*;
import java.awt.LayoutManager;
public class GridLayout {
public static void main(String[] args) {
Frame frame = new Frame("Grid layout");
frame.setLocation(10,10);
frame.setSize(400,400);
frame.setVisible(true);
GridLayout g1 = new GridLayout(2,1);
Panel p1 = new Panel(new BorderLayout());
Panel p2 = new Panel(new BorderLayout());
Panel p11 = new Panel(new GridLayout(2,1));
Panel p22 = new Panel(new GridLayout(2,2));
p1.add(new Button("Button"),BorderLayout.EAST);
p1.add(new Button("Button"),BorderLayout.WEST);
p11.add(new Button("Button"));
p11.add(new Button("Button"));
p1.add(p11,BorderLayout.CENTER);
p2.add(new Button("Button"),BorderLayout.EAST);
p2.add(new Button("Button"),BorderLayout.WEST);
for(int i = 0;i<4,i++){
p22.add(new Button("button"));
}
p2.add(p22,BorderLayout.CENTER);
frame.add(p1);
frame.add(p2);
}
} 展开
import javax.*;
import java.awt.LayoutManager;
public class GridLayout {
public static void main(String[] args) {
Frame frame = new Frame("Grid layout");
frame.setLocation(10,10);
frame.setSize(400,400);
frame.setVisible(true);
GridLayout g1 = new GridLayout(2,1);
Panel p1 = new Panel(new BorderLayout());
Panel p2 = new Panel(new BorderLayout());
Panel p11 = new Panel(new GridLayout(2,1));
Panel p22 = new Panel(new GridLayout(2,2));
p1.add(new Button("Button"),BorderLayout.EAST);
p1.add(new Button("Button"),BorderLayout.WEST);
p11.add(new Button("Button"));
p11.add(new Button("Button"));
p1.add(p11,BorderLayout.CENTER);
p2.add(new Button("Button"),BorderLayout.EAST);
p2.add(new Button("Button"),BorderLayout.WEST);
for(int i = 0;i<4,i++){
p22.add(new Button("button"));
}
p2.add(p22,BorderLayout.CENTER);
frame.add(p1);
frame.add(p2);
}
} 展开
展开全部
import java.awt.*;
import javax.*;
import java.awt.LayoutManager;
public class GridLayout {
public static void main(String[] args) {
Frame frame = new Frame("Grid layout");
frame.setLocation(10,10);
frame.setSize(400,400);
frame.setVisible(true);
GridLayout g1 = new GridLayout();
Panel p1 = new Panel(new BorderLayout());
Panel p2 = new Panel(new BorderLayout());
Panel p11 = new Panel();
Panel p22 = new Panel();
p1.add(new Button("Button"),BorderLayout.EAST);
p1.add(new Button("Button"),BorderLayout.WEST);
p11.add(new Button("Button"));
p11.add(new Button("Button"));
p1.add(p11,BorderLayout.CENTER);
p2.add(new Button("Button"),BorderLayout.EAST);
p2.add(new Button("Button"),BorderLayout.WEST);
for(int i = 0;i<4;i++){
p22.add(new Button("button"));
}
p2.add(p22,BorderLayout.CENTER);
frame.add(p1);
frame.add(p2);
}
}
import javax.*;
import java.awt.LayoutManager;
public class GridLayout {
public static void main(String[] args) {
Frame frame = new Frame("Grid layout");
frame.setLocation(10,10);
frame.setSize(400,400);
frame.setVisible(true);
GridLayout g1 = new GridLayout();
Panel p1 = new Panel(new BorderLayout());
Panel p2 = new Panel(new BorderLayout());
Panel p11 = new Panel();
Panel p22 = new Panel();
p1.add(new Button("Button"),BorderLayout.EAST);
p1.add(new Button("Button"),BorderLayout.WEST);
p11.add(new Button("Button"));
p11.add(new Button("Button"));
p1.add(p11,BorderLayout.CENTER);
p2.add(new Button("Button"),BorderLayout.EAST);
p2.add(new Button("Button"),BorderLayout.WEST);
for(int i = 0;i<4;i++){
p22.add(new Button("button"));
}
p2.add(p22,BorderLayout.CENTER);
frame.add(p1);
frame.add(p2);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询