Java Code Examples for java.awt.Component#BaselineResizeBehavior

The following examples show how to use java.awt.Component#BaselineResizeBehavior . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicLabelUI.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the component
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    super.getBaselineResizeBehavior(c);
    if (c.getClientProperty(BasicHTML.propertyKey) != null) {
        return Component.BaselineResizeBehavior.OTHER;
    }
    switch(((JLabel)c).getVerticalAlignment()) {
    case JLabel.TOP:
        return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
    case JLabel.BOTTOM:
        return Component.BaselineResizeBehavior.CONSTANT_DESCENT;
    case JLabel.CENTER:
        return Component.BaselineResizeBehavior.CENTER_OFFSET;
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 2
Source File: TitledBorder.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the border
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        Component c) {
    super.getBaselineResizeBehavior(c);
    switch (getPosition()) {
        case TitledBorder.ABOVE_TOP:
        case TitledBorder.TOP:
        case TitledBorder.BELOW_TOP:
            return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
        case TitledBorder.ABOVE_BOTTOM:
        case TitledBorder.BOTTOM:
        case TitledBorder.BELOW_BOTTOM:
            return JComponent.BaselineResizeBehavior.CONSTANT_DESCENT;
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 3
Source File: BasicLabelUI.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the component
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    super.getBaselineResizeBehavior(c);
    if (c.getClientProperty(BasicHTML.propertyKey) != null) {
        return Component.BaselineResizeBehavior.OTHER;
    }
    switch(((JLabel)c).getVerticalAlignment()) {
    case JLabel.TOP:
        return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
    case JLabel.BOTTOM:
        return Component.BaselineResizeBehavior.CONSTANT_DESCENT;
    case JLabel.CENTER:
        return Component.BaselineResizeBehavior.CENTER_OFFSET;
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 4
Source File: TitledBorder.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the border
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        Component c) {
    super.getBaselineResizeBehavior(c);
    switch (getPosition()) {
        case TitledBorder.ABOVE_TOP:
        case TitledBorder.TOP:
        case TitledBorder.BELOW_TOP:
            return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
        case TitledBorder.ABOVE_BOTTOM:
        case TitledBorder.BOTTOM:
        case TitledBorder.BELOW_BOTTOM:
            return JComponent.BaselineResizeBehavior.CONSTANT_DESCENT;
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 5
Source File: TitledBorder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the border
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        Component c) {
    super.getBaselineResizeBehavior(c);
    switch (getPosition()) {
        case TitledBorder.ABOVE_TOP:
        case TitledBorder.TOP:
        case TitledBorder.BELOW_TOP:
            return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
        case TitledBorder.ABOVE_BOTTOM:
        case TitledBorder.BOTTOM:
        case TitledBorder.BELOW_BOTTOM:
            return JComponent.BaselineResizeBehavior.CONSTANT_DESCENT;
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 6
Source File: TitledBorder.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the border
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        Component c) {
    super.getBaselineResizeBehavior(c);
    switch (getPosition()) {
        case TitledBorder.ABOVE_TOP:
        case TitledBorder.TOP:
        case TitledBorder.BELOW_TOP:
            return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
        case TitledBorder.ABOVE_BOTTOM:
        case TitledBorder.BOTTOM:
        case TitledBorder.BELOW_BOTTOM:
            return JComponent.BaselineResizeBehavior.CONSTANT_DESCENT;
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 7
Source File: BasicLabelUI.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the component
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    super.getBaselineResizeBehavior(c);
    if (c.getClientProperty(BasicHTML.propertyKey) != null) {
        return Component.BaselineResizeBehavior.OTHER;
    }
    switch(((JLabel)c).getVerticalAlignment()) {
    case JLabel.TOP:
        return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
    case JLabel.BOTTOM:
        return Component.BaselineResizeBehavior.CONSTANT_DESCENT;
    case JLabel.CENTER:
        return Component.BaselineResizeBehavior.CENTER_OFFSET;
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 8
Source File: BasicScrollPaneUI.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the component
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    super.getBaselineResizeBehavior(c);
    // Baseline is either from the header, in which case it's always
    // the same size and therefor can be created as CONSTANT_ASCENT.
    // If the header doesn't have a baseline than the baseline will only
    // be valid if it's BaselineResizeBehavior is
    // CONSTANT_ASCENT, so, return CONSTANT_ASCENT.
    return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
}
 
Example 9
Source File: BasicScrollPaneUI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the component
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    super.getBaselineResizeBehavior(c);
    // Baseline is either from the header, in which case it's always
    // the same size and therefor can be created as CONSTANT_ASCENT.
    // If the header doesn't have a baseline than the baseline will only
    // be valid if it's BaselineResizeBehavior is
    // CONSTANT_ASCENT, so, return CONSTANT_ASCENT.
    return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
}
 
Example 10
Source File: BasicScrollPaneUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the component
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    super.getBaselineResizeBehavior(c);
    // Baseline is either from the header, in which case it's always
    // the same size and therefor can be created as CONSTANT_ASCENT.
    // If the header doesn't have a baseline than the baseline will only
    // be valid if it's BaselineResizeBehavior is
    // CONSTANT_ASCENT, so, return CONSTANT_ASCENT.
    return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
}
 
Example 11
Source File: BasicScrollPaneUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the component
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    super.getBaselineResizeBehavior(c);
    // Baseline is either from the header, in which case it's always
    // the same size and therefor can be created as CONSTANT_ASCENT.
    // If the header doesn't have a baseline than the baseline will only
    // be valid if it's BaselineResizeBehavior is
    // CONSTANT_ASCENT, so, return CONSTANT_ASCENT.
    return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
}
 
Example 12
Source File: BasicScrollPaneUI.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of the component
 * changes as the size changes.
 *
 * @throws NullPointerException {@inheritDoc}
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    super.getBaselineResizeBehavior(c);
    // Baseline is either from the header, in which case it's always
    // the same size and therefor can be created as CONSTANT_ASCENT.
    // If the header doesn't have a baseline than the baseline will only
    // be valid if it's BaselineResizeBehavior is
    // CONSTANT_ASCENT, so, return CONSTANT_ASCENT.
    return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
}
 
Example 13
Source File: AbstractBorder.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of a component
 * changes as the size changes.  This method is primarily meant for
 * layout managers and GUI builders.
 * <p>
 * The default implementation returns
 * <code>BaselineResizeBehavior.OTHER</code>, subclasses that support
 * baseline should override appropriately.  Subclasses should
 * never return <code>null</code>; if the baseline can not be
 * calculated return <code>BaselineResizeBehavior.OTHER</code>.  Callers
 * should first ask for the baseline using
 * <code>getBaseline</code> and if a value &gt;= 0 is returned use
 * this method.  It is acceptable for this method to return a
 * value other than <code>BaselineResizeBehavior.OTHER</code> even if
 * <code>getBaseline</code> returns a value less than 0.
 *
 * @param c <code>Component</code> to return baseline resize behavior for
 * @return an enum indicating how the baseline changes as the border is
 *         resized
 * @see java.awt.Component#getBaseline(int,int)
 * @see java.awt.Component#getBaselineResizeBehavior()
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        Component c) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 14
Source File: AbstractBorder.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of a component
 * changes as the size changes.  This method is primarily meant for
 * layout managers and GUI builders.
 * <p>
 * The default implementation returns
 * <code>BaselineResizeBehavior.OTHER</code>, subclasses that support
 * baseline should override appropriately.  Subclasses should
 * never return <code>null</code>; if the baseline can not be
 * calculated return <code>BaselineResizeBehavior.OTHER</code>.  Callers
 * should first ask for the baseline using
 * <code>getBaseline</code> and if a value &gt;= 0 is returned use
 * this method.  It is acceptable for this method to return a
 * value other than <code>BaselineResizeBehavior.OTHER</code> even if
 * <code>getBaseline</code> returns a value less than 0.
 *
 * @param c <code>Component</code> to return baseline resize behavior for
 * @return an enum indicating how the baseline changes as the border is
 *         resized
 * @see java.awt.Component#getBaseline(int,int)
 * @see java.awt.Component#getBaselineResizeBehavior()
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        Component c) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 15
Source File: ComponentUI.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of he component
 * changes as the size changes.  This method is primarily meant for
 * layout managers and GUI builders.
 * <p>
 * This method returns <code>BaselineResizeBehavior.OTHER</code>.
 * Subclasses that support a baseline should override appropriately.
 *
 * @param c <code>JComponent</code> to return baseline resize behavior for
 * @return an enum indicating how the baseline changes as the component
 *         size changes
 * @throws NullPointerException if <code>c</code> is <code>null</code>
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 16
Source File: AbstractBorder.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of a component
 * changes as the size changes.  This method is primarily meant for
 * layout managers and GUI builders.
 * <p>
 * The default implementation returns
 * <code>BaselineResizeBehavior.OTHER</code>, subclasses that support
 * baseline should override appropriately.  Subclasses should
 * never return <code>null</code>; if the baseline can not be
 * calculated return <code>BaselineResizeBehavior.OTHER</code>.  Callers
 * should first ask for the baseline using
 * <code>getBaseline</code> and if a value &gt;= 0 is returned use
 * this method.  It is acceptable for this method to return a
 * value other than <code>BaselineResizeBehavior.OTHER</code> even if
 * <code>getBaseline</code> returns a value less than 0.
 *
 * @param c <code>Component</code> to return baseline resize behavior for
 * @return an enum indicating how the baseline changes as the border is
 *         resized
 * @see java.awt.Component#getBaseline(int,int)
 * @see java.awt.Component#getBaselineResizeBehavior()
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        Component c) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 17
Source File: ComponentUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of he component
 * changes as the size changes.  This method is primarily meant for
 * layout managers and GUI builders.
 * <p>
 * This method returns <code>BaselineResizeBehavior.OTHER</code>.
 * Subclasses that support a baseline should override appropriately.
 *
 * @param c <code>JComponent</code> to return baseline resize behavior for
 * @return an enum indicating how the baseline changes as the component
 *         size changes
 * @throws NullPointerException if <code>c</code> is <code>null</code>
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 18
Source File: AbstractBorder.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of a component
 * changes as the size changes.  This method is primarily meant for
 * layout managers and GUI builders.
 * <p>
 * The default implementation returns
 * <code>BaselineResizeBehavior.OTHER</code>, subclasses that support
 * baseline should override appropriately.  Subclasses should
 * never return <code>null</code>; if the baseline can not be
 * calculated return <code>BaselineResizeBehavior.OTHER</code>.  Callers
 * should first ask for the baseline using
 * <code>getBaseline</code> and if a value &gt;= 0 is returned use
 * this method.  It is acceptable for this method to return a
 * value other than <code>BaselineResizeBehavior.OTHER</code> even if
 * <code>getBaseline</code> returns a value less than 0.
 *
 * @param c <code>Component</code> to return baseline resize behavior for
 * @return an enum indicating how the baseline changes as the border is
 *         resized
 * @see java.awt.Component#getBaseline(int,int)
 * @see java.awt.Component#getBaselineResizeBehavior()
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        Component c) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 19
Source File: ComponentUI.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of he component
 * changes as the size changes.  This method is primarily meant for
 * layout managers and GUI builders.
 * <p>
 * This method returns <code>BaselineResizeBehavior.OTHER</code>.
 * Subclasses that support a baseline should override appropriately.
 *
 * @param c <code>JComponent</code> to return baseline resize behavior for
 * @return an enum indicating how the baseline changes as the component
 *         size changes
 * @throws NullPointerException if <code>c</code> is <code>null</code>
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    return Component.BaselineResizeBehavior.OTHER;
}
 
Example 20
Source File: ComponentUI.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns an enum indicating how the baseline of he component
 * changes as the size changes.  This method is primarily meant for
 * layout managers and GUI builders.
 * <p>
 * This method returns <code>BaselineResizeBehavior.OTHER</code>.
 * Subclasses that support a baseline should override appropriately.
 *
 * @param c <code>JComponent</code> to return baseline resize behavior for
 * @return an enum indicating how the baseline changes as the component
 *         size changes
 * @throws NullPointerException if <code>c</code> is <code>null</code>
 * @see javax.swing.JComponent#getBaseline(int, int)
 * @since 1.6
 */
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
        JComponent c) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    return Component.BaselineResizeBehavior.OTHER;
}