Swing layout manager

Null Layout
Null layout, also known as absolute layout manager, if a container to use absolute layout, then one of the components to call setBounds () method to determine the position in which display component, or components will not be displayed. If you do not like the interface development WindowsBuilder plug-ins, use absolute positioning would be a painful thing. The interface more complex cases, generally will not use absolute layout

FlowLayout
Use this layout manager component within the container from left to right or right to left by arrangement, if the remaining space is less than component, then the component will display in the new line.

BorderLayout
Certain container components default layout manager, it will container into NORTH, SOUTH, CENTER, WEST, EAST five regions, each region can be up to a component, it also only applies to container group pieces less (not more than five) of the layout manager. Use:
Container.add (component, BorderLayout.SOUTH);
If the second parameter is not specified, the default display in the BorderLayout.CENTER region.
If you add a region with multiple components, it only shows the last added component.

GridLayout
Grid layout manager, it will be divided into the designated container rows * columns a cell, add the order by component, in turn a component into a cell, you can specify the same form as the cell between the horizontal and vertical spacing, but it can not be cross-bank and inter-column. So, this layout manager is only applicable to container components arranged in a container class layout in tabular form.

GridBagLayout
Cross-bank and inter-column GridLayout can not, however, can GridBagLayout, GridLayout think GridBagLayout is based, because its principle is the container area is divided into several cells. But GridLayout powerful than function, not only cross-bank and inter-column, can also specify the container size changes, the components are the x-axis and y axis extension and elongation.
Each component managed by the GridBagLayout GridBagConstraints instance with the associated. Constraints specify the component's display area the object in a specific place grid position, and the component in its display area in the placement. Constraints object in addition to outside, GridBagLayout also consider each component of the minimum size and preferred size, to determine the size of components. Some properties of the GridBagConstraints following a brief description, if we understand the properties of native instructions, please refer to the official data sun
gridx, gridy: specify the components in a container within a cell row index and column index, such as in the upper left of the cell format, gridx to 0, gridy 0.
gridwidth, gridheight: the specified cell number of cross-bank and inter-column
fill: Fill the specified direction, may apply to horizontal, vertical or horizontal + vertical direction to fill the entire container.
ipadx, ipady: specify the component's internal padding, equivalent to the cell margin, that is, to components of the minimum width or height to add how much space. This property can not fathom in my practice, which works (sometimes fill, sometimes not filled)
insets: the specified components of the external fill, equivalent to the cell spacing.
Anchor: When the component is smaller than the size of display area available to use, specify the component's position in the display area. See Below:
-------------------------------------------------
| FIRST_LINE_START PAGE_START FIRST_LINE_END |
| |
| |
| LINE_START CENTER LINE_END |
| |
| |
| LAST_LINE_START PAGE_END LAST_LINE_END |
-------------------------------------------------

weightx, weighty: the specified container size changes, the x or y direction of the stretching rate.

For more information GridBagLayout see JDK API or related information, an example is given below.

BoxLayout
Vertical or horizontal layout allows more of the components of the layout manager. Joint work with Box, Box is a lightweight component uses BoxLayout. Box of thinking is the component within the container as a Box (box), between the Box and the Box you can create a number of non-visible area, divided into:
Glue: the equivalent of glue and stuck the two box, it will automatically fill along the vertical or horizontal direction between the two box area is not visible
Strut: specify the height (width) and vertical (horizontal) spacing of Glue
RigidArea: specify both the height and width of Strut
Please see below an example of the effect achieved in the sample with the same effect as GridBagLayout

SpringLayout
SpringLayout is a more specific layout manager, which by the definition of container and container components of the constraints to achieve the layout. With Spring, SpringLayout.Constraints combination. In this talk a little bit before Spring
Spring is like a spring, which can be extended to the maximum, can shrink to a minimun, under normal circumstances, its length is prefferenceSize, changes in vessel size, its value according to the previous three series of rules under a specific value calculated . Spring is an abstract class that provides max, sum of static function
SpringLayout.Constraints, will manage the size and location of components bound to change the way the containers are stored in SpringLayout control, it has x, y, width and height attributes, which is similar to a Rectangle. However, in the Constraints object, these properties have Spring values is, not an integer. In addition, you can use the constraint property by the four sides (east, south, west and north) operating a Constraints object.
Components and component constraint is defined by edges, such as a textfield to the left of the number of distance away from the right side of label. Side of the formula given below:
WEST = x
NORTH = y
EAST = x + width
SOUTH = y + height
Here's an official example:
Pane using the Spring container container layout manager, pane under a label and a textfield.

Summary
Swing-SWT layout manager does not feel so, in reality, interface development, according to the actual situation in a flexible use of multiple layout managers, like SWT uses a GridLayout almost on it. In view of the profound personal understanding is not enough, more information needs to see a sun official website description of the layout manager:

<script> </ script>

分类:Java 时间:2010-04-02 人气:268
分享到:
blog comments powered by Disqus

相关文章

  • Eclipse plug-ins to use Ruby Development Tools 2009-09-09

    Eclipse plug-ins to use Ruby Development Tools Document options Send as an e-mail this page Tomcat Application Development Download IBM open-source J2EE application server, WAS CE new version V1.1 Level: Intermediate Neal Ford ( neal.ford @ gmail.com ), A

  • Through plug-ins to extend the AIR application [Translation] 2010-03-22

    Transfer from: Adobe AIR Team Blog Translation: Little Raccoon Already have several customers and partners asked whether we could prepare for the AIR application, a secure plug-in architecture. Although we have assumed that this can be done, but I finally

  • position: absolute relative absolute positioning and relative positioning 2010-07-21

    The following references are purely information. . . . Omitted 1000.. . . CSS2.0 HandBook on the explanation: Absolute value of this property will set the object off the the normal document flow around it, regardless of the absolute positioning layou

  • Absolute positioning of div layers, so do not cover the flash 2009-07-01

    Today, a picture scroll of the case, that is to click on to enlarge the view, with my blog Even just plug that picture -ins - highslide to the whole, the effect of JS things good! Transplant go very smoothly, but there is a flash ad to enlarge old ph ...

  • MyEclipse shortcut keys and plug-ins Guinness 2009-08-12

    Related Articles: Eclipse summary of commonly used classification of shortcut keys Let us work together more efficient use of Eclipse Is that we usually use eclipse shortcut bar Recommended circle: IntelliJ IDEA More Recommended <script type="text

  • Jquery plug-ins extend the easy drag (Reprinted wood Wildfox) 2010-06-02

    Jquery plug-ins extend the easy drag jquery drag the plug-ins to achieve, try a few, interface is one bug, but too much bad code and complex changes, to give up. Found today called easydrag, but not flexible with the next, so to expand a bit, now can spec

  • Based on jQuery framework to collect some of the development control / jquery plug-ins 2010-06-13

    Horizontal accordion: jQuery Development based on jQuery, a very simple horizontally folding control. Home: http://letmehaveblog.blogspot.com/2007/10/haccordion-simple-horizontal-accordion.html (not found) Download: http://letmehaveblog.blogspot.com/2007/

  • Based on jQuery framework for the development to collect some of the controls / jquery plug-ins 2010-11-01

    Horizontal accordion: jQuery Development based on jQuery, a very simple horizontal fold control. Home: http://letmehaveblog.blogspot.com/2007/10/haccordion-simple-horizontal-accordion.html (not found) Download: http://letmehaveblog.blogspot.com/2007/10/ha

  • "Chapter XVII write plug-ins" released 2009-03-09

    Is a long chapter, but as any chapter of the book, as are the Maven community as the original author of the committer, the content is very exciting, although written a Maven plug-ins before, but in the translation process, I benefited . And a friend

  • Hibernate Tools for Eclipse plug-ins to install and use 2009-03-30

    Always want to discard Myeclipse, today finally found a reason for not using it, Eclipse plug-ins so much, to do anything. The following is how to use Hibernate to Hibernatetools Development Hibernate plug-ins installed One Ways Start the latest Elcipse (

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.293 (s). 12 q(s)