Quaqua 8.0 2011-10-02

ch.randelshofer.quaqua
Class QuaquaLayoutStyle15

java.lang.Object
  extended by org.jdesktop.layout.LayoutStyle
      extended by ch.randelshofer.quaqua.QuaquaLayoutStyle15

public class QuaquaLayoutStyle15
extends LayoutStyle

A QuaquaLayoutStyle15 can be queried for the preferred gaps between two JComponents, or between a JComponent and a parent Container.

To compile this class, you need the experimental SwingLayout package.

This class is here for backwards compatibilty with J2SE5.

Version:
$Id: QuaquaLayoutStyle15.java 361 2010-11-21 11:19:20Z wrandelshofer $
Author:
Werner Randelshofer

Field Summary
 
Fields inherited from class org.jdesktop.layout.LayoutStyle
INDENT, RELATED, UNRELATED
 
Constructor Summary
QuaquaLayoutStyle15()
          Creates a new instance.
 
Method Summary
 int getContainerGap(javax.swing.JComponent component, int position, java.awt.Container parent)
          Returns the amount of space to position a component inside its parent.
 int getPreferredGap(javax.swing.JComponent component1, javax.swing.JComponent component2, int type, int position, java.awt.Container parent)
          Returns the amount of space to use between two components.
 
Methods inherited from class org.jdesktop.layout.LayoutStyle
getSharedInstance, setSharedInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuaquaLayoutStyle15

public QuaquaLayoutStyle15()
Creates a new instance.

Method Detail

getPreferredGap

public int getPreferredGap(javax.swing.JComponent component1,
                           javax.swing.JComponent component2,
                           int type,
                           int position,
                           java.awt.Container parent)
Returns the amount of space to use between two components. The return value indicates the distance to place component2 relative to component1. For example, the following returns the amount of space to place between component2 and component1 when component2 is placed vertically above component1:
   int gap = getPreferredGap(component1, component2,
                             LayoutStyle.RELATED,
                             SwingConstants.NORTH, parent);
 
The type parameter indicates the type of gap being requested. It can be one of the following values:
RELATED If the two components will be contained in the same parent and are showing similar logically related items, use RELATED.
UNRELATED If the two components will be contained in the same parent but show logically unrelated items use UNRELATED.
INDENT Used to obtain the preferred distance to indent a component relative to another. For example, if you want to horizontally indent a JCheckBox relative to a JLabel use INDENT. This is only useful for the horizontal axis.

It's important to note that some look and feels may not distinguish between RELATED and UNRELATED.

The return value is not intended to take into account the current size and position of component2 or component1. The return value may take into consideration various properties of the components. For example, the space may vary based on font size, or the preferred size of the component.

Overrides:
getPreferredGap in class LayoutStyle
Parameters:
component1 - the JComponent component2 is being placed relative to
component2 - the JComponent being placed
type - how the two components are being placed
position - the position component2 is being placed relative to component1; one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST
parent - the parent of component2; this may differ from the actual parent and may be null
Returns:
the amount of space to place between the two components
Throws:
java.lang.IllegalArgumentException - if position is not one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST; type not one of INDENT, RELATED or UNRELATED; or component1 or component2 is null

getContainerGap

public int getContainerGap(javax.swing.JComponent component,
                           int position,
                           java.awt.Container parent)
Returns the amount of space to position a component inside its parent.

Overrides:
getContainerGap in class LayoutStyle
Parameters:
component - the Component being positioned
position - the position component is being placed relative to its parent; one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST
parent - the parent of component; this may differ from the actual parent and may be null
Returns:
the amount of space to place between the component and specified edge
Throws:
java.lang.IllegalArgumentException - if position is not one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST; or component is null

Copyright 2003-2007 (c) Werner Randelshofer.
All rights reserved.