Java Doc for GroupLayout.java in  » IDE-Netbeans » cvsclient » org » jdesktop » layout » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » cvsclient » org.jdesktop.layout 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jdesktop.layout.GroupLayout

GroupLayout
public class GroupLayout implements LayoutManager2(Code)
GroupLayout is a LayoutManager that hierarchically groups components to achieve common, and not so common, layouts. Grouping is done by instances of the Group class. GroupLayout supports two types of groups:
Sequential:A sequential group positions its child elements sequentially, one after another.
Parallel:A parallel group positions its child elements in the same space on top of each other. Parallel groups can also align the child elements along their baseline.
Each Group can contain any number of child groups, Components or gaps. GroupLayout treats each axis independently. That is, there is a group representing the horizontal axis, and a separate group representing the vertical axis. The horizontal group is responsible for setting the x and width of its contents, where as the vertical group is responsible for setting the y and height of its contents.

The following code builds a simple layout consisting of two labels in one column, followed by two textfields in the next column:

 JComponent panel = ...;
 GroupLayout layout = new GroupLayout(panel);
 panel.setLayout(layout);
 layout.setAutocreateGaps(true);
 layout.setAutocreateContainerGaps(true);
 GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
 hGroup.add(layout.createParallelGroup().add(label1).add(label2)).
 add(layout.createParallelGroup().add(tf1).add(tf2));
 layout.setHorizontalGroup(hGroup);
 GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
 vGroup.add(layout.createParallelGroup(GroupLayout.BASELINE).add(label1).add(tf1)).
 add(layout.createParallelGroup(GroupLayout.BASELINE).add(label2).add(tf2));
 layout.setVerticalGroup(vGroup);
 

This layout consists of the following:

  • The horizontal axis consists of a sequential group containing two parallel groups. The first parallel group consists of the labels, with the second parallel group consisting of the text fields.
  • The vertical axis similarly consists of a sequential group containing two parallel groups. The parallel groups align their contents along the baseline. The first parallel group consists of the first label and text field, and the second group consists of the second label and text field.
There are a couple of things to notice in this code:
  • You need not explicitly add the components to the container, this is indirectly done by using one of the add methods.
  • The various add methods of Groups return themselves. This allows for easy chaining of invocations. For example, group.add(label1).add(label2); is equivalent to group.add(label1);group.add(label2);.
  • There are no public constructors for the Groups, instead use the create methods of GroupLayout.
GroupLayout offer the ability to automatically insert the appropriate gap between components. This can be turned on using the setAutocreateGaps() method. Similarly you can use the setAutocreateContainerGaps() method to insert gaps between the components and the container.
version:
   $Revision$
author:
   Tomas Pavek
author:
   Jan Stola
author:
   Scott Violet

Inner Class :abstract class Spring
Inner Class :abstract public class Group extends Spring
Inner Class :public class SequentialGroup extends Group
Inner Class :public class ParallelGroup extends Group
Inner Class :class ComponentSpring extends Spring
Inner Class :class PaddingSpring extends Spring
Inner Class :class GapSpring extends Spring

Field Summary
final public static  intBASELINE
     Possible alignment type.
final public static  intCENTER
     Possible alignment type.
final public static  intDEFAULT_SIZE
     Possible value for the add methods that takes a Component.
final public static  intHORIZONTAL
     Possible argument when linking sizes of components.
final public static  intLEADING
     Possible alignment type.
final public static  intPREFERRED_SIZE
     Possible value for the add methods that takes a Component.
final public static  intTRAILING
     Possible alignment type.
final public static  intVERTICAL
     Possible argument when linking sizes of components.

Constructor Summary
public  GroupLayout(Container host)
     Creates a GroupLayout for the specified JComponent.

Method Summary
public  voidaddLayoutComponent(String name, Component component)
     Notification that a Component has been added to the parent container.
public  voidaddLayoutComponent(Component component, Object constraints)
     Notification that a Component has been added to the parent container.
public  ParallelGroupcreateParallelGroup()
     Creates and returns a ParallelGroup with a LEADING alignment.
public  ParallelGroupcreateParallelGroup(int alignment)
     Creates and returns an ParallelGroup.
public  ParallelGroupcreateParallelGroup(int alignment, boolean resizable)
     Creates and returns an ParallelGroup.
public  SequentialGroupcreateSequentialGroup()
     Creates and returns a SequentialGroup.
public  booleangetAutocreateContainerGaps()
     Returns whether or not gaps between the container and the first/last components should automatically be created.
public  booleangetAutocreateGaps()
     Returns true if gaps between components are automatically be created.
public  GroupgetHorizontalGroup()
     Returns the Group that is responsible for layout along the horizontal axis.
public  floatgetLayoutAlignmentX(Container parent)
     Returns the alignment along the x axis.
public  floatgetLayoutAlignmentY(Container parent)
     Returns the alignment along the y axis.
public  GroupgetVerticalGroup()
     Returns the ParallelGroup that is responsible for layout along the vertical axis.
public  voidinvalidateLayout(Container parent)
     Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
public  voidlayoutContainer(Container parent)
     Lays out the specified container.
public  voidlinkSize(Component[] components)
     Forces the set of components to have the same size.
public  voidlinkSize(Component[] components, int axis)
     Forces the set of components to have the same size.
public  DimensionmaximumLayoutSize(Container parent)
     Returns the maximum size for the specified container.
public  DimensionminimumLayoutSize(Container parent)
     Returns the minimum size for the specified container.
public  DimensionpreferredLayoutSize(Container parent)
     Returns the preferred size for the specified container.
public  voidremoveLayoutComponent(Component comp)
     Notification that a Component has been removed from the parent container.
public  voidreplace(Component existingComponent, Component newComponent)
     Removes an existing component replacing it with the specified component.
public  voidsetAutocreateContainerGaps(boolean autocreatePadding)
     Sets whether or not gaps between the container and the first/last components should automatically be created.
public  voidsetAutocreateGaps(boolean autocreatePadding)
     Sets whether or not a gap between components should automatically be created.
public  voidsetHorizontalGroup(Group group)
     Sets the Group that is responsible for layout along the horizontal axis.
public  voidsetVerticalGroup(Group group)
     Sets the Group that is responsible for layout along the vertical axis.
public  StringtoString()
     Returns a textual description of this GroupLayout.

Field Detail
BASELINE
final public static int BASELINE(Code)
Possible alignment type. Indicates the elements should aligned along their baseline.
See Also:   GroupLayout.createParallelGroup(int)



CENTER
final public static int CENTER(Code)
Possible alignment type. Indicates the elements should centered in the spaced provided.
See Also:   GroupLayout.createParallelGroup(int)



DEFAULT_SIZE
final public static int DEFAULT_SIZE(Code)
Possible value for the add methods that takes a Component. Indicates the size from the component should be used.



HORIZONTAL
final public static int HORIZONTAL(Code)
Possible argument when linking sizes of components. Specifies the the two component should share the same size along the horizontal axis.
See Also:   GroupLayout.linkSize(java.awt.Component[],int)



LEADING
final public static int LEADING(Code)
Possible alignment type. Indicates the elements should be aligned to the origin. For the horizontal axis with a left to right orientation this means aligned to the left.
See Also:   GroupLayout.createParallelGroup(int)



PREFERRED_SIZE
final public static int PREFERRED_SIZE(Code)
Possible value for the add methods that takes a Component. Indicates the preferred size should be used.



TRAILING
final public static int TRAILING(Code)
Possible alignment type. Indicates the elements should be aligned to the end. For the horizontal axis with a left to right orientation this means aligned to the right.
See Also:   GroupLayout.createParallelGroup(int)



VERTICAL
final public static int VERTICAL(Code)
Possible argument when linking sizes of components. Specifies the the two component should share the same size along the vertical axis.
See Also:   GroupLayout.linkSize(java.awt.Component[],int)




Constructor Detail
GroupLayout
public GroupLayout(Container host)(Code)
Creates a GroupLayout for the specified JComponent.
Parameters:
  host - the Container to layout
throws:
  IllegalArgumentException - if host is null




Method Detail
addLayoutComponent
public void addLayoutComponent(String name, Component component)(Code)
Notification that a Component has been added to the parent container. Developers should not invoke this method directly, instead you should use one of the Group methods to add a Component.
Parameters:
  name - the string to be associated with the component
Parameters:
  component - the Component to be added



addLayoutComponent
public void addLayoutComponent(Component component, Object constraints)(Code)
Notification that a Component has been added to the parent container. You should not invoke this method directly, instead you should use one of the Group methods to add a Component.
Parameters:
  component - The component added
Parameters:
  constraints - Description of where to place the component.



createParallelGroup
public ParallelGroup createParallelGroup()(Code)
Creates and returns a ParallelGroup with a LEADING alignment. This is a cover method for the more general createParallelGroup(int) method. a new ParallelGroup
See Also:   GroupLayout.createParallelGroup(int)



createParallelGroup
public ParallelGroup createParallelGroup(int alignment)(Code)
Creates and returns an ParallelGroup. The alignment specifies how children elements should be positioned when the the parallel group is given more space than necessary. For example, if a ParallelGroup with an alignment of TRAILING is given 100 pixels and a child only needs 50 pixels, the child will be positioned at the position 50.
Parameters:
  alignment - alignment for the elements of the Group, oneof LEADING, TRAILING,CENTER or BASELINE.
throws:
  IllegalArgumentException - if alignment is not one ofLEADING, TRAILING,CENTER or BASELINE a new ParallelGroup



createParallelGroup
public ParallelGroup createParallelGroup(int alignment, boolean resizable)(Code)
Creates and returns an ParallelGroup. The alignment specifies how children elements should be positioned when the the parallel group is given more space than necessary. For example, if a ParallelGroup with an alignment of TRAILING is given 100 pixels and a child only needs 50 pixels, the child will be positioned at the position 50.
Parameters:
  alignment - alignment for the elements of the Group, oneof LEADING, TRAILING,CENTER or BASELINE.
Parameters:
  resizable - whether or not the group is resizable. If the groupis not resizable the min/max size will be the same as thepreferred.
throws:
  IllegalArgumentException - if alignment is not one ofLEADING, TRAILING,CENTER or BASELINE a new ParallelGroup



createSequentialGroup
public SequentialGroup createSequentialGroup()(Code)
Creates and returns a SequentialGroup. a new SequentialGroup



getAutocreateContainerGaps
public boolean getAutocreateContainerGaps()(Code)
Returns whether or not gaps between the container and the first/last components should automatically be created. The default is false. whether or not the gaps between the container and thefirst/last components should automatically be created



getAutocreateGaps
public boolean getAutocreateGaps()(Code)
Returns true if gaps between components are automatically be created. true if gaps between components should automatically be created



getHorizontalGroup
public Group getHorizontalGroup()(Code)
Returns the Group that is responsible for layout along the horizontal axis. ParallelGroup responsible for layout alongthe horizontal axis.



getLayoutAlignmentX
public float getLayoutAlignmentX(Container parent)(Code)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Parameters:
  parent - Container hosting this LayoutManager
throws:
  IllegalArgumentException - if parent is notthe same Container that this was created with alignment



getLayoutAlignmentY
public float getLayoutAlignmentY(Container parent)(Code)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Parameters:
  parent - Container hosting this LayoutManager
throws:
  IllegalArgumentException - if parent is notthe same Container that this was created with alignment



getVerticalGroup
public Group getVerticalGroup()(Code)
Returns the ParallelGroup that is responsible for layout along the vertical axis. ParallelGroup responsible for layout alongthe vertical axis.



invalidateLayout
public void invalidateLayout(Container parent)(Code)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
Parameters:
  parent - Container hosting this LayoutManager
throws:
  IllegalArgumentException - if parent is notthe same Container that this was created with



layoutContainer
public void layoutContainer(Container parent)(Code)
Lays out the specified container.
Parameters:
  parent - the container to be laid out
throws:
  IllegalStateException - if any of the components added tothis layout are not in both a horizontal and vertical group



linkSize
public void linkSize(Component[] components)(Code)
Forces the set of components to have the same size. This can be used multiple times to force any number of components to share the same size.

Linked Components are not be resizable.
Parameters:
  components - Components to force to have same size.
throws:
  IllegalArgumentException - if components isnull, or contains null.




linkSize
public void linkSize(Component[] components, int axis)(Code)
Forces the set of components to have the same size. This can be used multiple times to force any number of components to share the same size.

Linked Components are not be resizable.
Parameters:
  components - Components to force to have same size.
Parameters:
  axis - Axis to bind size, one of HORIZONTAL, VERTICAL orHORIZONTAL | VERTICAL
throws:
  IllegalArgumentException - if components isnull, or contains null.
throws:
  IllegalArgumentException - if axis does notcontain HORIZONTAL or VERTICAL




maximumLayoutSize
public Dimension maximumLayoutSize(Container parent)(Code)
Returns the maximum size for the specified container.
Parameters:
  parent - the container to return size for
throws:
  IllegalArgumentException - if parent is notthe same Container that this was created with
throws:
  IllegalStateException - if any of the components added tothis layout are not in both a horizontal and vertical group
See Also:   java.awt.Container.getMaximumSize



minimumLayoutSize
public Dimension minimumLayoutSize(Container parent)(Code)
Returns the minimum size for the specified container.
Parameters:
  parent - the container to return size for
throws:
  IllegalArgumentException - if parent is notthe same Container that this was created with
throws:
  IllegalStateException - if any of the components added tothis layout are not in both a horizontal and vertical group
See Also:   java.awt.Container.getMinimumSize



preferredLayoutSize
public Dimension preferredLayoutSize(Container parent)(Code)
Returns the preferred size for the specified container.
Parameters:
  parent - the container to return size for
throws:
  IllegalArgumentException - if parent is notthe same Container that this was created with
throws:
  IllegalStateException - if any of the components added tothis layout are not in both a horizontal and vertical group
See Also:   java.awt.Container.getPreferredSize



removeLayoutComponent
public void removeLayoutComponent(Component comp)(Code)
Notification that a Component has been removed from the parent container. You should not invoke this method directly, instead invoke remove on the parent Container.
Parameters:
  comp - the component to be removed
See Also:   java.awt.Component.remove



replace
public void replace(Component existingComponent, Component newComponent)(Code)
Removes an existing component replacing it with the specified component.
Parameters:
  existingComponent - the Component that should be removed andreplaced with newComponent
Parameters:
  newComponent - the Component to put in existingComponents place
throws:
  IllegalArgumentException - is either of the Components are null orif existingComponent is not being managed by this layout manager



setAutocreateContainerGaps
public void setAutocreateContainerGaps(boolean autocreatePadding)(Code)
Sets whether or not gaps between the container and the first/last components should automatically be created. The default is false.
Parameters:
  autocreatePadding - whether or not to automatically creategaps between the container and first/last components.



setAutocreateGaps
public void setAutocreateGaps(boolean autocreatePadding)(Code)
Sets whether or not a gap between components should automatically be created. For example, if this is true and you add two components to a SequentialGroup a gap between the two will automatically be created. The default is false.
Parameters:
  autocreatePadding - whether or not to automatically created a gapbetween components and the container



setHorizontalGroup
public void setHorizontalGroup(Group group)(Code)
Sets the Group that is responsible for layout along the horizontal axis.
Parameters:
  group - Group responsible for layout alongthe horizontal axis
throws:
  IllegalArgumentException - if group is null



setVerticalGroup
public void setVerticalGroup(Group group)(Code)
Sets the Group that is responsible for layout along the vertical axis.
Parameters:
  group - Group responsible for layout alongthe vertical axis.
throws:
  IllegalArgumentException - if group is null.



toString
public String toString()(Code)
Returns a textual description of this GroupLayout. The return value is intended for debugging purposes only. textual description of this GroupLayout



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.