java::awt::FlowLayout Class Reference

Inheritance diagram for java::awt::FlowLayout:

Inheritance graph
java::lang::Objectjava::lang::Interfacejava::awt::LayoutManager
[legend]
Collaboration diagram for java::awt::FlowLayout:

Collaboration graph
java::lang::Objectjava::lang::Interfacejava::awt::LayoutManager
[legend]

List of all members.


Detailed Description

A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph.

Flow layouts are typically used to arrange buttons in a panel. It will arrange buttons left to right until no more buttons fit on the same line. Each line is centered.

For example, the following picture shows an applet using the flow layout manager (its default layout manager) to position three buttons:

FlowLayout-1.gif

Here is the code for this applet:


<blockquote>
 import java.awt.*;
 import java.applet.Applet;

 public class myButtons extends Applet {
     Button button1, button2, button3;
     public void init() {
         button1 = new Button("Ok");
         button2 = new Button("Open");
         button3 = new Button("Close");
         add(button1);
         add(button2);
         add(button3);
     }
 }
 
</blockquote>

A flow layout lets each component assume its natural (preferred) size.

Version:
1.46, 01/23/03
Author:
Arthur van Hoff

Sami Shaio

Since:
JDK1.0

Public Types

enum  ALIGNMENT_TYPE {
  LEFT = 0, CENTER, RIGHT, LEADING,
  TRAILING
}

Public Member Functions

 FlowLayout (jint align=CENTER, jint hgap=5, jint vgap=5)
 Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps.
virtual jint getAlignment () const
 Gets the alignment for this layout.
virtual void setAlignment (jint align)
 Sets the alignment for this layout.
virtual jint getHgap () const
 Gets the horizontal gap between components.
virtual void setHgap (jint hgap)
 Sets the horizontal gap between components.
virtual jint getVgap () const
 Gets the vertical gap between components.
virtual void setVgap (jint vgap)
 Sets the vertical gap between components.
virtual void addLayoutComponent (const String &name, const Ref< Component > &comp)
 Adds the specified component to the layout.
virtual void removeLayoutComponent (const Ref< Component > &comp)
 Removes the specified component from the layout.
virtual Dimension minimumLayoutSize (const Container &target) const
 Returns the minimum dimensions needed to layout the visible components contained in the specified target container.
virtual Dimension preferredLayoutSize (const Container &target) const
 Returns the preferred dimensions for this layout given the visible components in the specified target container.
virtual void layoutContainer (const Container &target)
 Lays out the container.
virtual String toString () const
 Returns a string representation of this FlowLayout object and its values.

Protected Attributes

jint align
 align is the property that determines how each row distributes empty space.
jint hgap
 The flow layout manager allows a seperation of components with gaps.
jint vgap
 The flow layout manager allows a seperation of components with gaps.
 REGISTER_MEMBERS

Member Enumeration Documentation

enum java::awt::FlowLayout::ALIGNMENT_TYPE

Enumerator:
LEFT  This value indicates that each row of components should be left-justified.
CENTER  This value indicates that each row of components should be centered.
RIGHT  This value indicates that each row of components should be right-justified.
LEADING  This value indicates that each row of components should be justified to the leading edge of the container's orientation, for example, to the left in left-to-right orientations.

See also:
java.awt.Component::getComponentOrientation

java.awt.ComponentOrientation

Since:
1.2 Package-private pending API change approval
TRAILING  This value indicates that each row of components should be justified to the trailing edge of the container's orientation, for example, to the right in left-to-right orientations.

See also:
java.awt.Component::getComponentOrientation

java.awt.ComponentOrientation

Since:
1.2 Package-private pending API change approval


Constructor & Destructor Documentation

java::awt::FlowLayout::FlowLayout ( jint  align = CENTER,
jint  hgap = 5,
jint  vgap = 5 
)

Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps.

The value of the alignment argument must be one of FlowLayout.LEFT, FlowLayout.RIGHT, or FlowLayout.CENTER.

Parameters:
align the alignment value
hgap the horizontal gap between components
vgap the vertical gap between components


Member Function Documentation

virtual jint java::awt::FlowLayout::getAlignment (  )  const [virtual]

Gets the alignment for this layout.

Possible values are FlowLayout.LEFT, FlowLayout.RIGHT, FlowLayout.CENTER, FlowLayout.LEADING, or FlowLayout.TRAILING.

Returns:
the alignment value for this layout
See also:
java.awt.FlowLayout::setAlignment
Since:
JDK1.1

virtual void java::awt::FlowLayout::setAlignment ( jint  align  )  [virtual]

Sets the alignment for this layout.

Possible values are

Parameters:
align one of the alignment values shown above
See also:
getAlignment()
Since:
JDK1.1

virtual jint java::awt::FlowLayout::getHgap (  )  const [virtual]

Gets the horizontal gap between components.

Returns:
the horizontal gap between components
See also:
java.awt.FlowLayout::setHgap
Since:
JDK1.1

virtual void java::awt::FlowLayout::setHgap ( jint  hgap  )  [virtual]

Sets the horizontal gap between components.

Parameters:
hgap the horizontal gap between components
See also:
java.awt.FlowLayout::getHgap
Since:
JDK1.1

virtual jint java::awt::FlowLayout::getVgap (  )  const [virtual]

Gets the vertical gap between components.

Returns:
the vertical gap between components
See also:
java.awt.FlowLayout::setVgap
Since:
JDK1.1

virtual void java::awt::FlowLayout::setVgap ( jint  vgap  )  [virtual]

Sets the vertical gap between components.

Parameters:
vgap the vertical gap between components
See also:
java.awt.FlowLayout::getVgap
Since:
JDK1.1

virtual void java::awt::FlowLayout::addLayoutComponent ( const String name,
const Ref< Component > &  comp 
) [virtual]

Adds the specified component to the layout.

Not used by this class.

Parameters:
name the name of the component
comp the component to be added

Implements java::awt::LayoutManager.

virtual void java::awt::FlowLayout::removeLayoutComponent ( const Ref< Component > &  comp  )  [virtual]

Removes the specified component from the layout.

Not used by this class.

Parameters:
comp the component to remove
See also:
java.awt.Container::removeAll

Implements java::awt::LayoutManager.

virtual Dimension java::awt::FlowLayout::minimumLayoutSize ( const Container target  )  const [virtual]

Returns the minimum dimensions needed to layout the visible components contained in the specified target container.

Parameters:
target the component which needs to be laid out
Returns:
the minimum dimensions to lay out the subcomponents of the specified container
See also:
preferredLayoutSize

java.awt.Container

java.awt.Container::doLayout

Implements java::awt::LayoutManager.

virtual Dimension java::awt::FlowLayout::preferredLayoutSize ( const Container target  )  const [virtual]

Returns the preferred dimensions for this layout given the visible components in the specified target container.

Parameters:
target the component which needs to be laid out
Returns:
the preferred dimensions to lay out the subcomponents of the specified container
See also:
Container

minimumLayoutSize

java.awt.Container::getPreferredSize

Implements java::awt::LayoutManager.

virtual void java::awt::FlowLayout::layoutContainer ( const Container target  )  [virtual]

Lays out the container.

This method lets each component take its preferred size by reshaping the components in the target container in order to satisfy the alignment of this FlowLayout object.

Parameters:
target the specified component being laid out
See also:
Container

java.awt.Container::doLayout

Implements java::awt::LayoutManager.

virtual String java::awt::FlowLayout::toString (  )  const [virtual]

Returns a string representation of this FlowLayout object and its values.

Returns:
a string representation of this layout

Reimplemented from java::lang::Object.


Member Data Documentation

jint java::awt::FlowLayout::align [protected]

align is the property that determines how each row distributes empty space.

It can be one of the following values:

LEFT RIGHT CENTER LEADING TRAILING

See also:
getAlignment

setAlignment

jint java::awt::FlowLayout::hgap [protected]

The flow layout manager allows a seperation of components with gaps.

The horizontal gap will specify the space between components.

See also:
getHgap()

setHgap(int)

jint java::awt::FlowLayout::vgap [protected]

The flow layout manager allows a seperation of components with gaps.

The vertical gap will specify the space between rows.

See also:
getHgap()

setHgap(int)

java::awt::FlowLayout::REGISTER_MEMBERS [protected]

Reimplemented from java::awt::LayoutManager.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:55:58 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3