Swing layout manager

sponsored links
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

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.

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.

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.

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:
| |
| |
| |
| |

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.

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 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
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.

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>
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Swing layout manager

  • For the past two days, ruby development web site performance test summary

    This is only the individual test, is also a ruby beginner test, if ill-Optimize and causing significant error also invited Members to make the exhibitions. Rails vs Rack vs Merb: Merb worse performance than Rails, but documents, rich plug-ins, plus Rack c

  • js events Guinness 2

    Event source object event.srcElement.tagName event.srcElement.type Capture release event.srcElement.setCapture (); event.srcElement.releaseCapture (); Events button event.keyCode event.shiftKey event.altKey event.ctrlKey Return value events event.returnVa

  • Eclipse to run using the specified JVM m2eclipse plugin can not find tools.jar

    Used the m2eclipse plug-ins using struts2 when com.sun necessary to rely on the default-tools.jar, specifically because at the struts-annotations bag designated default-tools.jar <profile> <id> default-tools.jar </ id> <activatio ...

  • Struts + Spring + Hibernate practice

    Tools: Eclipse3.1, MyEclipse4.03, Tomcat5.5.9, Properties Editor plug-ins, MySql4.1.13 New construction: the name for the login Create Struts framework Create index.jsp, add a link to login.jsp Press Ctrl + N, to create login.jsp, LoginAction, the use of

  • Great Design

    Understand the principle with the practice, details the relationship between thought, we'll go have selectively study the details, we must work on the details because the details are important to you to use the technical details of implementation ...

  • jBPM Development Getting Started Guide

    Although the workflow is still immature stage of development, not even a recognized standard. But its application has already been launched in the Express, indicating the market's demand for job-flow framework are urgent and enormous. Backgrounds of o

  • Object-oriented design principles 11

    What is object-oriented design? Contains what? The benefits of it are what? Required to pay what you do? In today's age, ask these questions seem to be foolish, because this year almost every software developer knows how to use some sort of objec ...

  • Openfire Plugin Developer's Guide

    Introduction Openfire features plug-ins are enhanced. This document is a guide to developers to create plug-ins. The structure of a plug-in Plug-ins Plug-ins openfireHome stored in the directory. When deploying a plug-in jar or war file, it will automatic

  • JS charts extjs implementation tools can be combined

    OpenFlashChart brief introduction by valensoft 2009-1-10 8:29:00 OpenFlashChart is an open source Flash and Javascript to the technical foundation for the free chart, using it to create some very useful analysis of the effect of the statements of the char

  • hibernate to use the principle of

    The use of hibernate, implementation of data persistence. Has the following several processes. One configuration database connection information. Hibernate.config 2 configuration mapping. 3 use: the use of the process are the following steps: 3.1: Ge ...

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries