Example usage for javax.swing JSplitPane getWidth

List of usage examples for javax.swing JSplitPane getWidth

Introduction

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

Prototype

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

Source Link

Document

Returns the current width 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 a  2  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();//from   w  w w. j  a va 2  s.c om
    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  w w.j ava  2s .  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/*from  w  w  w  .j a  v  a  2  s .  co 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/*from   www  .j a v  a  2  s.c o  m*/
 * 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;/* ww w .ja  va2  s . c o  m*/
    if (mysplit.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        max = mysplit.getWidth();
    } else {
        max = mysplit.getHeight();
    }
    return new Double(max * pos).intValue();
}