List of utility methods to do JSplitPane
JSplitPane | getSplitPane(boolean vertical, JComponent left, JComponent right) Helper that creates a SplitPane JSplitPane result = new JSplitPane(vertical ? JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT, left, right); result.setDividerSize(3); result.setDividerLocation(0.5D); return result; |
double | getSplitPaneComponentLength(JSplitPane splitPane, Component component) get Split Pane Component Length Dimension size = component.getPreferredSize();
return (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) ? size.getWidth() : size.getHeight();
|
int | getSplitPaneSize(JSplitPane splitPane) get Split Pane Size if (splitPane == null) { return 0; boolean horiz = splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT ? true : false; return horiz ? splitPane.getWidth() : splitPane.getHeight(); |
JSplitPane | hsplit(Component left, Component right, double resizeWeight) Create a horizontally aligned JSplitPane JSplitPane split = hsplit(left, right);
split.setResizeWeight(resizeWeight);
return split;
|
float | rememberOldHeightRatio(JSplitPane splitPane) remember Old Height Ratio int oldHeight = splitPane.getHeight(); float oldFraction = ((oldHeight == 0) ? 0 : ((float) splitPane.getDividerLocation()) / oldHeight); return oldFraction; |
void | sanitizeSplitPaneDivider(JSplitPane splitPane) sanitize Split Pane Divider Component firstComponent = splitPane.getLeftComponent(); Component secondComponent = splitPane.getRightComponent(); double firstLength = getSplitPaneComponentLength(splitPane, firstComponent); double secondLength = getSplitPaneComponentLength(splitPane, secondComponent); double preferredWeight = firstLength / (firstLength + secondLength); splitPane.setResizeWeight(preferredWeight); |
JSplitPane | setDividerLocation(final JSplitPane splitter, final int position) Force divider location for a JSplitPan with 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); ... |
void | setNewHeightRatio(JSplitPane splitPane, JComponent comp, float oldFraction, int v1, int v2) set New Height Ratio int h = comp.getHeight(); splitPane.setDividerLocation( (int) ((oldFraction <= 0.01) ? v1 * h / v2 : splitPane.getHeight() * oldFraction)); |
void | setSplitDivider(final JSplitPane split, float proportion) Moves the supplied JSplitPane divider to the specified 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); ... |
void | setSplitPaneDividerColor(final JSplitPane pane, final Color color) Change the colour of a JSplitPane divider. final SplitPaneUI splitUI; splitUI = pane.getUI(); if (splitUI instanceof BasicSplitPaneUI) { final BasicSplitPaneDivider divider; divider = ((BasicSplitPaneUI) splitUI).getDivider(); if (divider != null) { final Border divBorder; final Border newBorder; ... |