标签:object mod size 尺寸 his The imp static event
GridLayout 可使容器中的各个组件呈网格状布局,平局占据容器的空间,即使容器的大小发生变化,每个组件还是平均占据容器的空间。
和FlowLayout一样,GridLayout也是按照从上到下,从左到右的规律进行排列的。
1 package TomAwt; 2 3 4 import java.awt.*; 5 import java.awt.event.*; 6 public class TomAwt_15 extends Frame implements ActionListener{ 7 Button b=new Button("打开对话框"); 8 //create a model dialog object whose owner is this frame 9 Dialog dlg=new Dialog(this,"你好",true); 10 public TomAwt_15(){ 11 super("对话框示例"); 12 add(b); 13 b.addActionListener(this); 14 pack(); //使框架尺寸适应组件的大小 15 setVisible(true); 16 } 17 //handle the button_click events 18 public void actionPerformed(ActionEvent e){ 19 dlg.setLayout(new FlowLayout()); 20 dlg.add(new Label("你好")); 21 dlg.add(new Button("确定")); 22 dlg.setSize(100,60); 23 //show the dialog 24 dlg.show(); 25 } 26 public static void main(String[] args){ 27 new TomAwt_15(); 28 } 29 }
标签:object mod size 尺寸 his The imp static event
原文地址:https://www.cnblogs.com/borter/p/9425446.html