每个容器都有一个布局管理器

布局管理器(LayoutManager):每个容器都有一个布局管理器,当容器需要对某个组件进行定位或判断其大小、尺寸时,就会调用其对应的布局管理器。

使用布局管理器可以实现跨平台的特性,并且获得动态的布局效果。

布局管理器负责管理组件的排列顺序、大小和位置。

不同的布局管理器使用不同的布局策略,容器可以通过选择不同的布局管理器来决定如何布局。

 

 1 package TomAwt;
 2 
 3 
 4 import java.applet.Applet;
 5 import java.awt.*;
 6 public class TomAwt_17 extends Applet{
 7     private TextArea textArea1,textArea2;
 8     public void init()
 9     {
10         //creating 2 10*20 TextAreas
11         textArea1=new TextArea("Read-only Text!",10,20);
12         textArea2=new TextArea(10,20);
13         //set textArea1 read-only
14         textArea1.setEditable(false);
15         add(textArea1);
16         add(textArea2);
17     }
18 }

 

posted @ 2018-08-05 14:27  borter  阅读(290)  评论(0编辑  收藏  举报