Example usage for javax.swing JSplitPane getHeight

List of usage examples for javax.swing JSplitPane getHeight

Introduction

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

Prototype

@BeanProperty(bound = false)
public int getHeight() 

Source Link

Document

Returns the current height of this component.

Usage

From source file:Main.java

public static JSplitPane setDividerLocation(final JSplitPane splitter, final double proportion) {
    if (splitter.isShowing()) {
        if (splitter.getWidth() > 0 && splitter.getHeight() > 0) {
            splitter.setDividerLocation(proportion);
        } else {/* ww w.  ja  v a2 s. c om*/
            splitter.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent ce) {
                    splitter.removeComponentListener(this);
                    setDividerLocation(splitter, proportion);
                }
            });
        }
    } else {
        splitter.addHierarchyListener(new HierarchyListener() {
            @Override
            public void hierarchyChanged(HierarchyEvent e) {
                if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && splitter.isShowing()) {
                    splitter.removeHierarchyListener(this);
                    setDividerLocation(splitter, proportion);
                }
            }
        });
    }
    return splitter;
}

From source file:Main.java

public static float getDividerProportion(JSplitPane splitPane) {
    if (splitPane == null)
        return 0;

    int size = splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT ? splitPane.getWidth()
            : splitPane.getHeight();
    int divLoc = splitPane.getDividerLocation();
    return size == 0 ? 0 : (float) divLoc / ((float) size - splitPane.getDividerSize());
}

From source file:Main.java

/**
 * Force divider location for a JSplitPan with int position.
 *
 * @param splitter//from w  ww .  j a  v a2s. c o  m
 * @param position
 * @return
 */
public static JSplitPane setDividerLocation(final JSplitPane splitter, final int position) {
    if (splitter.isShowing()) {
        if (splitter.getWidth() > 0 && splitter.getHeight() > 0) {
            splitter.setDividerLocation(position);
        } else {
            splitter.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent ce) {
                    splitter.removeComponentListener(this);
                    setDividerLocation(splitter, position);
                }
            });
        }
    } else {
        splitter.addHierarchyListener(new HierarchyListener() {
            @Override
            public void hierarchyChanged(HierarchyEvent e) {
                if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && splitter.isShowing()) {
                    splitter.removeHierarchyListener(this);
                    setDividerLocation(splitter, position);
                }
            }
        });
    }
    return splitter;
}

From source file:Main.java

/**
 * Force divider location for a JSplitPan in percent.
 *
 * @param splitter/* w  ww . ja  v  a2s.  c  o m*/
 * @param proportion
 * @return
 */
public static JSplitPane setDividerLocation(final JSplitPane splitter, final double proportion) {
    if (splitter.isShowing()) {
        if (splitter.getWidth() > 0 && splitter.getHeight() > 0) {
            splitter.setDividerLocation(proportion);
        } else {
            splitter.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent ce) {
                    splitter.removeComponentListener(this);
                    setDividerLocation(splitter, proportion);
                }
            });
        }
    } else {
        splitter.addHierarchyListener(new HierarchyListener() {
            @Override
            public void hierarchyChanged(HierarchyEvent e) {
                if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && splitter.isShowing()) {
                    splitter.removeHierarchyListener(this);
                    setDividerLocation(splitter, proportion);
                }
            }
        });
    }
    return splitter;
}

From source file:Main.java

public static int getSplitPaneSize(JSplitPane splitPane) {
    if (splitPane == null)
        return 0;

    boolean horiz = splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT ? true : false;
    return horiz ? splitPane.getWidth() : splitPane.getHeight();
}

From source file:st.jigasoft.dbutil.view.DUReport.java

/**
 * Definer o tamanho padrao do divider//  w ww  .j  a  va  2 s . c  om
 * W as width
 * H as Heigth
 * @param key
 * @param sepTableGarfico
 * @param parcent 
 */
private void defineDivider(char key, JSplitPane sepTableGarfico, double parcent) {
    double cParcent = parcent / 100;
    int size = (key == 'H') ? sepTableGarfico.getHeight() : sepTableGarfico.getWidth();
    int location = (int) (size * cParcent);
    sepTableGarfico.setDividerLocation(location);
}

From source file:op.tools.SYSTools.java

public static Integer getDividerInAbsolutePosition(JSplitPane mysplit, double pos) {
    int max;//from  w ww.j  a  v  a 2s .  c  o m
    if (mysplit.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        max = mysplit.getWidth();
    } else {
        max = mysplit.getHeight();
    }
    return new Double(max * pos).intValue();
}