Java Doc for BoxLayout.java in  » 6.0-JDK-Core » swing » javax » swing » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.swing.BoxLayout

All known Subclasses:   javax.swing.plaf.basic.DefaultMenuLayout,  javax.swing.plaf.synth.DefaultMenuLayout,
BoxLayout
public class BoxLayout implements LayoutManager2,Serializable(Code)
A layout manager that allows multiple components to be laid out either vertically or horizontally. The components will not wrap so, for example, a vertical arrangement of components will stay vertically arranged when the frame is resized.

The following text describes this graphic.

Nesting multiple panels with different combinations of horizontal and vertical gives an effect similar to GridBagLayout, without the complexity. The diagram shows two panels arranged horizontally, each of which contains 3 components arranged vertically.

The BoxLayout manager is constructed with an axis parameter that specifies the type of layout that will be done. There are four choices:

X_AXIS - Components are laid out horizontally from left to right.
Y_AXIS - Components are laid out vertically from top to bottom.
LINE_AXIS - Components are laid out the way words are laid out in a line, based on the container's ComponentOrientation property. If the container's ComponentOrientation is horizontal then components are laid out horizontally, otherwise they are laid out vertically. For horizontal orientations, if the container's ComponentOrientation is left to right then components are laid out left to right, otherwise they are laid out right to left. For vertical orientations components are always laid out from top to bottom.
PAGE_AXIS - Components are laid out the way text lines are laid out on a page, based on the container's ComponentOrientation property. If the container's ComponentOrientation is horizontal then components are laid out vertically, otherwise they are laid out horizontally. For horizontal orientations, if the container's ComponentOrientation is left to right then components are laid out left to right, otherwise they are laid out right to left.  For vertical orientations components are always laid out from top to bottom.

For all directions, components are arranged in the same order as they were added to the container.

BoxLayout attempts to arrange components at their preferred widths (for horizontal layout) or heights (for vertical layout). For a horizontal layout, if not all the components are the same height, BoxLayout attempts to make all the components as high as the highest component. If that's not possible for a particular component, then BoxLayout aligns that component vertically, according to the component's Y alignment. By default, a component has a Y alignment of 0.5, which means that the vertical center of the component should have the same Y coordinate as the vertical centers of other components with 0.5 Y alignment.

Similarly, for a vertical layout, BoxLayout attempts to make all components in the column as wide as the widest component. If that fails, it aligns them horizontally according to their X alignments. For PAGE_AXIS layout, horizontal alignment is done based on the leading edge of the component. In other words, an X alignment value of 0.0 means the left edge of a component if the container's ComponentOrientation is left to right and it means the right edge of the component otherwise.

Instead of using BoxLayout directly, many programs use the Box class. The Box class is a lightweight container that uses a BoxLayout. It also provides handy methods to help you use BoxLayout well. Adding components to multiple nested boxes is a powerful way to get the arrangement you want.

For further information and examples see How to Use BoxLayout, a section in The Java Tutorial.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder .
See Also:   Box
See Also:   java.awt.ComponentOrientation
See Also:   JComponent.getAlignmentX
See Also:   JComponent.getAlignmentY
author:
   Timothy Prinzing
version:
   1.42 05/05/07



Field Summary
final public static  intLINE_AXIS
     Specifies that components should be laid out in the direction of a line of text as determined by the target container's ComponentOrientation property.
final public static  intPAGE_AXIS
     Specifies that components should be laid out in the direction that lines flow across a page as determined by the target container's ComponentOrientation property.
final public static  intX_AXIS
     Specifies that components should be laid out left to right.
final public static  intY_AXIS
     Specifies that components should be laid out top to bottom.

Constructor Summary
public  BoxLayout(Container target, int axis)
     Creates a layout manager that will lay out components along the given axis.
 BoxLayout(Container target, int axis, PrintStream dbg)
     Constructs a BoxLayout that produces debugging messages.
Parameters:
  target - the container that needs to be laid out
Parameters:
  axis - the axis to lay out components along.

Method Summary
public  voidaddLayoutComponent(String name, Component comp)
     Not used by this class.
public  voidaddLayoutComponent(Component comp, Object constraints)
     Not used by this class.
 voidcheckContainer(Container target)
    
 voidcheckRequests()
    
final public  intgetAxis()
     Returns the axis that was used to lay out components.
public synchronized  floatgetLayoutAlignmentX(Container target)
     Returns the alignment along the X axis for the container. If the box is horizontal, the default alignment will be returned.
public synchronized  floatgetLayoutAlignmentY(Container target)
     Returns the alignment along the Y axis for the container. If the box is vertical, the default alignment will be returned.
final public  ContainergetTarget()
     Returns the container that uses this layout manager.
public synchronized  voidinvalidateLayout(Container target)
     Indicates that a child has changed its layout related information, and thus any cached calculations should be flushed.

This method is called by AWT when the invalidate method is called on the Container.

public  voidlayoutContainer(Container target)
     Called by the AWT when the specified container needs to be laid out.
public  DimensionmaximumLayoutSize(Container target)
     Returns the maximum dimensions the target container can use to lay out the components it contains.
public  DimensionminimumLayoutSize(Container target)
     Returns the minimum dimensions needed to lay out the components contained in the specified target container.
public  DimensionpreferredLayoutSize(Container target)
     Returns the preferred dimensions for this layout, given the components in the specified target container.
public  voidremoveLayoutComponent(Component comp)
     Not used by this class.

Field Detail
LINE_AXIS
final public static int LINE_AXIS(Code)
Specifies that components should be laid out in the direction of a line of text as determined by the target container's ComponentOrientation property.



PAGE_AXIS
final public static int PAGE_AXIS(Code)
Specifies that components should be laid out in the direction that lines flow across a page as determined by the target container's ComponentOrientation property.



X_AXIS
final public static int X_AXIS(Code)
Specifies that components should be laid out left to right.



Y_AXIS
final public static int Y_AXIS(Code)
Specifies that components should be laid out top to bottom.




Constructor Detail
BoxLayout
public BoxLayout(Container target, int axis)(Code)
Creates a layout manager that will lay out components along the given axis.
Parameters:
  target - the container that needs to be laid out
Parameters:
  axis - the axis to lay out components along. Can be one of:BoxLayout.X_AXIS,BoxLayout.Y_AXIS,BoxLayout.LINE_AXIS orBoxLayout.PAGE_AXIS
exception:
  AWTError - if the value of axis is invalid



BoxLayout
BoxLayout(Container target, int axis, PrintStream dbg)(Code)
Constructs a BoxLayout that produces debugging messages.
Parameters:
  target - the container that needs to be laid out
Parameters:
  axis - the axis to lay out components along. Can be one of:BoxLayout.X_AXIS,BoxLayout.Y_AXIS,BoxLayout.LINE_AXIS orBoxLayout.PAGE_AXIS
Parameters:
  dbg - the stream to which debugging messages should be sent,null if none




Method Detail
addLayoutComponent
public void addLayoutComponent(String name, Component comp)(Code)
Not used by this class.
Parameters:
  name - the name of the component
Parameters:
  comp - the component



addLayoutComponent
public void addLayoutComponent(Component comp, Object constraints)(Code)
Not used by this class.
Parameters:
  comp - the component
Parameters:
  constraints - constraints



checkContainer
void checkContainer(Container target)(Code)



checkRequests
void checkRequests()(Code)



getAxis
final public int getAxis()(Code)
Returns the axis that was used to lay out components. Returns one of: BoxLayout.X_AXIS, BoxLayout.Y_AXIS, BoxLayout.LINE_AXIS or BoxLayout.PAGE_AXIS the axis that was used to lay out components
since:
   1.6



getLayoutAlignmentX
public synchronized float getLayoutAlignmentX(Container target)(Code)
Returns the alignment along the X axis for the container. If the box is horizontal, the default alignment will be returned. Otherwise, the alignment needed to place the children along the X axis will be returned.
Parameters:
  target - the container the alignment >= 0.0f && <= 1.0f
exception:
  AWTError - if the target isn't the container specified to theBoxLayout constructor



getLayoutAlignmentY
public synchronized float getLayoutAlignmentY(Container target)(Code)
Returns the alignment along the Y axis for the container. If the box is vertical, the default alignment will be returned. Otherwise, the alignment needed to place the children along the Y axis will be returned.
Parameters:
  target - the container the alignment >= 0.0f && <= 1.0f
exception:
  AWTError - if the target isn't the container specified to theBoxLayout constructor



getTarget
final public Container getTarget()(Code)
Returns the container that uses this layout manager. the container that uses this layout manager
since:
   1.6



invalidateLayout
public synchronized void invalidateLayout(Container target)(Code)
Indicates that a child has changed its layout related information, and thus any cached calculations should be flushed.

This method is called by AWT when the invalidate method is called on the Container. Since the invalidate method may be called asynchronously to the event thread, this method may be called asynchronously.
Parameters:
  target - the affected container
exception:
  AWTError - if the target isn't the container specified to theBoxLayout constructor




layoutContainer
public void layoutContainer(Container target)(Code)
Called by the AWT when the specified container needs to be laid out.
Parameters:
  target - the container to lay out
exception:
  AWTError - if the target isn't the container specified to theBoxLayout constructor



maximumLayoutSize
public Dimension maximumLayoutSize(Container target)(Code)
Returns the maximum dimensions the target container can use to lay out the components it contains.
Parameters:
  target - the container that needs to be laid out the dimenions >= 0 && <= Integer.MAX_VALUE
exception:
  AWTError - if the target isn't the container specified to theBoxLayout constructor
See Also:   BoxLayout.preferredLayoutSize
See Also:   BoxLayout.minimumLayoutSize



minimumLayoutSize
public Dimension minimumLayoutSize(Container target)(Code)
Returns the minimum dimensions needed to lay out the components contained in the specified target container.
Parameters:
  target - the container that needs to be laid out the dimensions >= 0 && <= Integer.MAX_VALUE
exception:
  AWTError - if the target isn't the container specified to theBoxLayout constructor
See Also:   BoxLayout.preferredLayoutSize
See Also:   BoxLayout.maximumLayoutSize



preferredLayoutSize
public Dimension preferredLayoutSize(Container target)(Code)
Returns the preferred dimensions for this layout, given the components in the specified target container.
Parameters:
  target - the container that needs to be laid out the dimensions >= 0 && <= Integer.MAX_VALUE
exception:
  AWTError - if the target isn't the container specified to theBoxLayout constructor
See Also:   Container
See Also:   BoxLayout.minimumLayoutSize
See Also:   BoxLayout.maximumLayoutSize



removeLayoutComponent
public void removeLayoutComponent(Component comp)(Code)
Not used by this class.
Parameters:
  comp - the component



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.