Example usage for javax.swing JSplitPane isVisible

List of usage examples for javax.swing JSplitPane isVisible

Introduction

In this page you can find the example usage for javax.swing JSplitPane isVisible.

Prototype

@Transient
public boolean isVisible() 

Source Link

Document

Determines whether this component should be visible when its parent is visible.

Usage

From source file:Main.java

/**
 * Moves the supplied <code>JSplitPane</code> divider to the specified <code>proportion</code>.
 * Valid values for <code>proportion</code> range from <code>0.0F<code>
 * to <code>1.0F</code>.  For example, a <code>proportion</code> of <code>0.3F</code> will move the
 * divider to 30% of the "size" (<i>width</i> for horizontal split, <i>height</i> for vertical split) of the
 * split container that contains the specified <code>Dockable</code>.  If a <code>proportion</code> of less
 * than <code>0.0F</code> is supplied, the value </code>0.0F</code> is used.  If a <code>proportion</code>
 * greater than <code>1.0F</code> is supplied, the value </code>1.0F</code> is used.
 * <br/>//w  w w.j a  va  2s .  c  om
 * This method should be effective regardless of whether the split layout in question has been fully realized
 * and is currently visible on the screen.  This should alleviate common problems associated with setting
 * percentages of unrealized <code>Component</code> dimensions, which are initially <code>0x0</code> before
 * the <code>Component</code> has been rendered to the screen.
 * <br/>
 * If the specified <code>JSplitPane</code> is <code>null</code>, then this method returns with no action
 * taken.
 *
 * @param split the <code>JSplitPane</code> whose divider location is to be set.
 * @param proportion a double-precision floating point value that specifies a percentage,
 * from zero (top/left) to 1.0 (bottom/right)
 * @see #getSplitPaneSize(JSplitPane)
 * @see JSplitPane#setDividerLocation(double)
 */
public static void setSplitDivider(final JSplitPane split, float proportion) {
    if (split == null)
        return;

    proportion = Math.max(0f, proportion);
    final float percent = Math.min(1f, proportion);
    int size = getSplitPaneSize(split);

    if (split.isVisible() && size > 0 && EventQueue.isDispatchThread()) {
        split.setDividerLocation(proportion);
        split.validate();
        return;
    }

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            setSplitDivider(split, percent);
        }
    });
}