java learnging

一块探讨JAVA的奥妙吧
posts - 34, comments - 27, trackbacks - 0, articles - 22

    AWT是JFC(Java基本类)的核心,为JFC的构成提供了以下的基本结构:

  • 代理事件模型
  • 轻量构件
  • 剪贴板和数据传输
  • 打印和无鼠标操作

    Java抽象窗口工具集有四个主要的类,即:构件类(Component)、容器类(Container)、图形类(Graphics)、和布局管理类(LayoutManager和LayoutMangager2)。容器包含构件,布局管理器确定容器内构件的位置和形状。图形(Graphics)类提供在构件中显示文本框和图形的方法。

1.强制一个容器布置它的构件

    在任何时间给定的构件都是有效(valid)或无效(invalid)的。无效的构件需要被布置,而有效的构件不需要。访问一个 无效容器(它的同位体已经产生)的validate()引起对容器layout()方法的调用。使构件无效的过程不仅使构件自己变得无效,而且也会使构件所在的容器变的无效。
使构件无效的Component和Container方法:
void Component.addNotify()
void Component.show() (invalidates parent container)
void Component.hide() (invalidates parent container)
void Component.reshap(int x,int y,int width,int height)
void Component.setSize(int width,int height)
void Component.setBounds(int x,int y,int width,int height)
void Component.setLayout(LayoutManager)
void Container.add(Component)
void Container.remove(Component)
void Container.removeAll(Component)
void Container.setLayout(LayoutManager)
因此我们可以把希望重新布置的构件设置为无效,然后调用该构件父容器的validate()方法即可。


只有注册用户登录后才能发表评论。


网站导航: