This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.awt
enum Component.BaselineResizeBehavior

java.lang.Object extended by java.lang.Enum extended by java.awt.Component.BaselineResizeBehavior
All Implemented Interfaces:
Serializable, Comparable

public static final enum Component.BaselineResizeBehavior
extends Enum

Enumeration of the common ways the baseline of a component can change as the size changes. The baseline resize behavior is primarily for layout managers that need to know how the position of the baseline changes as the component size changes. In general the baseline resize behavior will be valid for sizes greater than or equal to the minimum size (the actual minimum size; not a developer specified minimum size). For sizes smaller than the minimum size the baseline may change in a way other than the baseline resize behavior indicates. Similarly, as the size approaches Integer.MAX_VALUE and/or Short.MAX_VALUE the baseline may change in a way other than the baseline resize behavior indicates.


Field Summary
static Component.BaselineResizeBehavior CENTER_OFFSET
          Indicates the baseline remains a fixed distance from the center of the component.
static Component.BaselineResizeBehavior CONSTANT_ASCENT
          Indicates the baseline remains fixed relative to the y-origin.
static Component.BaselineResizeBehavior CONSTANT_DESCENT
          Indicates the baseline remains fixed relative to the height and does not change as the width is varied.
static Component.BaselineResizeBehavior OTHER
          Indicates the baseline resize behavior can not be expressed using any of the other constants.
 
Method Summary
static Component.BaselineResizeBehavior

          
static Component.BaselineResizeBehavior[]

          
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER_OFFSET

public static final Component.BaselineResizeBehavior CENTER_OFFSET
Indicates the baseline remains a fixed distance from the center of the component. That is, for any height H the difference between getBaseline(w, H) and H / 2 is the same (plus or minus one depending upon rounding error).

Because of possible rounding errors it is recommended you ask for the baseline with two consecutive heights and use the return value to determine if you need to pad calculations by 1. The following shows how to calculate the baseline for any height:

   Dimension preferredSize = component.getPreferredSize();
   int baseline = getBaseline(preferredSize.width,
                              preferredSize.height);
   int nextBaseline = getBaseline(preferredSize.width,
                                  preferredSize.height + 1);
   // Amount to add to height when calculating where baseline
   // lands for a particular height:
   int padding = 0;
   // Where the baseline is relative to the mid point
   int baselineOffset = baseline - height / 2;
   if (preferredSize.height % 2 == 0 &&
       baseline != nextBaseline) {
       padding = 1;
   }
   else if (preferredSize.height % 2 == 1 &&
            baseline == nextBaseline) {
       baselineOffset--;
       padding = 1;
   }
   // The following calculates where the baseline lands for
   // the height z:
   int calculatedBaseline = (z + padding) / 2 + baselineOffset;
 

CONSTANT_ASCENT

public static final Component.BaselineResizeBehavior CONSTANT_ASCENT
Indicates the baseline remains fixed relative to the y-origin. That is, getBaseline returns the same value regardless of the height or width. For example, a JLabel containing non-empty text with a vertical alignment of TOP should have a baseline type of CONSTANT_ASCENT.

CONSTANT_DESCENT

public static final Component.BaselineResizeBehavior CONSTANT_DESCENT
Indicates the baseline remains fixed relative to the height and does not change as the width is varied. That is, for any height H the difference between H and getBaseline(w, H) is the same. For example, a JLabel containing non-empty text with a vertical alignment of BOTTOM should have a baseline type of CONSTANT_DESCENT.

OTHER

public static final Component.BaselineResizeBehavior OTHER
Indicates the baseline resize behavior can not be expressed using any of the other constants. This may also indicate the baseline varies with the width of the component. This is also returned by components that do not have a baseline.
Method Detail

valueOf

public static Component.BaselineResizeBehavior valueOf(String name)
Parameters:
name

values

public static Component.BaselineResizeBehavior[] values()


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.