布局管理器
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
or right aligned
FlowLayout Demo
FlowLayout Demo
BorderLayout
BorderLayout
Arranges components into five regions – north, south, east, west and center
Content Pane – 默然为 BorderLayout 布局 可更改
Container contentPane = frame.getContentPane(); contentPane.setLayout(new FlowLayout());
常见布局管理器
Layout manager Description
Default for JFrames (and other windows). Arranges the components into five areas: NORTH, SOUTH, EAST, WEST and CENTER.
Arranges the components into rows and columns.
Implements interface LayoutM源自文库nager2 Provides horizontal gap spacing and
vertical gap spacing
7
BorderLayout Demo
11.17.3 GridLayout
GridLayout
Divides container into a grid Every component has the same width and
Complex GUIs often require multiple panels to arrange their components properly
13
练习
Call the Component class's setbounds method for each of the container's children.
Call the Component class's repaint method.
Using Panels to Manage More Complex Layouts
FlowLayout
FlowLayout
Simplest layout manager Components are placed left to right in the
order they are added Components can be left aligned, centered
FlowLayout
BorderLayout GridLayout
Default for javax.swing.JPanel. Places components sequentially (left to right) in the order they were added. It is also possible to specify the order of the components by using the Container method add, which takes a Component and an integer index position as arguments.
height
9
GridLayout Demo
其它布局
BorderLayout BoxLayout CardLayout FlowLayout GridBagLayout GridLayout GroupLayout SpringLayout
绝对布局
Set the container's layout manager to null by calling setLayout(null).
GUI 布局管理器
简介 FlowLayout BorderLayout GridLayout 其它 LayoutManager 组合布局
布局管理器
负责容器中各组件的位置和大小,两种容器: JPanel – 默认为 FlowLayout 布局,可更改
JPanel panel = new JPanel(new BorderLayout());
FlowLayout Demo
FlowLayout Demo
BorderLayout
BorderLayout
Arranges components into five regions – north, south, east, west and center
Content Pane – 默然为 BorderLayout 布局 可更改
Container contentPane = frame.getContentPane(); contentPane.setLayout(new FlowLayout());
常见布局管理器
Layout manager Description
Default for JFrames (and other windows). Arranges the components into five areas: NORTH, SOUTH, EAST, WEST and CENTER.
Arranges the components into rows and columns.
Implements interface LayoutM源自文库nager2 Provides horizontal gap spacing and
vertical gap spacing
7
BorderLayout Demo
11.17.3 GridLayout
GridLayout
Divides container into a grid Every component has the same width and
Complex GUIs often require multiple panels to arrange their components properly
13
练习
Call the Component class's setbounds method for each of the container's children.
Call the Component class's repaint method.
Using Panels to Manage More Complex Layouts
FlowLayout
FlowLayout
Simplest layout manager Components are placed left to right in the
order they are added Components can be left aligned, centered
FlowLayout
BorderLayout GridLayout
Default for javax.swing.JPanel. Places components sequentially (left to right) in the order they were added. It is also possible to specify the order of the components by using the Container method add, which takes a Component and an integer index position as arguments.
height
9
GridLayout Demo
其它布局
BorderLayout BoxLayout CardLayout FlowLayout GridBagLayout GridLayout GroupLayout SpringLayout
绝对布局
Set the container's layout manager to null by calling setLayout(null).
GUI 布局管理器
简介 FlowLayout BorderLayout GridLayout 其它 LayoutManager 组合布局
布局管理器
负责容器中各组件的位置和大小,两种容器: JPanel – 默认为 FlowLayout 布局,可更改
JPanel panel = new JPanel(new BorderLayout());