首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Java Swing 探索(1)LayoutManager

2012-12-22 
Java Swing 探索(一)LayoutManager?来源:http://blog.csdn.net/chelkim/archive/2009/01/28/3854043.aspxB

Java Swing 探索(一)LayoutManager

?

来源:http://blog.csdn.net/chelkim/archive/2009/01/28/3854043.aspx

    BorderLayout
  1. FlowLayout

  2. GridLayout

  3. GridBagLayout

  4. CardLayout

  5. BoxLayout

1.BorderLayout

java.lang.Object

--java.awt.BorderLayout

将版面划分成东、西、南、北、中五个区域,将添加的组件按指定位置放置。

  • ??? BorderLayout.EAST
  • ??? BorderLayout.WEST
  • ??? BorderLayout.SOUTH
  • ??? BorderLayout.NORTH
  • ??? BorderLayout.CENTER

    构造函数:

    BorderLayout()

    建立组件间无间距的BorderLayout

    BorderLayout(int hgap,int vgap)

    建立组件间水平间距为hgap,垂直间距为vgap的BorderLayout

    例一:

    ?

    在上例代码的第13,14行之间插入以下代码

    ?

    2.FlowLayout

    java.lang.Object

    --java.awt.FlowLayout

    组件按从左到右而后从上到下的顺序依次排列,一行不能放完则折到下一行。

    ?

    构造函数

    FlowLayout()

    建立一个默认为居中对齐,组件彼此有5单位的水平与垂直间距的FlowLayout

    FlowLayout(int align)

    建立一个可设置排列方式且组件彼此有5单位的水平与垂直间距的FlowLayout

    FlowLayout(int align,int hgap,int vgap)

    建立一个可设置排列方式与组件间距的FlowLayout

    例二:

    ?

    view plaintext-decoration: none; color: #a0a0a0; background-image: none; background-color: inherit; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border

热点排行