Java Code Examples for javax.swing.JSplitPane#getRightComponent()

The following examples show how to use javax.swing.JSplitPane#getRightComponent() . 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: DocumentEditor.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * TODO: to remove? doesn't seems to be used anywhere.
 */
protected void updateSplitLocation(JSplitPane split, int foo) {
  Component left = split.getLeftComponent();
  Component right = split.getRightComponent();
  if(left == null) {
    split.setDividerLocation(0);
    return;
  }
  if(right == null) {
    split.setDividerLocation(1);
    return;
  }
  Dimension leftPS = left.getPreferredSize();
  Dimension rightPS = right.getPreferredSize();
  double location =
      split.getOrientation() == JSplitPane.HORIZONTAL_SPLIT
          ? (double)leftPS.width / (leftPS.width + rightPS.width)
          : (double)leftPS.height / (leftPS.height + rightPS.height);
  split.setDividerLocation(location);
}
 
Example 2
Source File: StyledSplitPaneUI.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int getMinimumDividerLocation(JSplitPane pane) {
	int leftMin = super.getMinimumDividerLocation(pane);
	Component second = pane.getRightComponent();
	if ((second != null) && second.isVisible()) {
		Dimension paneSize = splitPane.getSize();
		Dimension maxSize = second.getMaximumSize();
		Insets insets = pane.getInsets();
		if (pane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
			leftMin = Math.max(leftMin, paneSize.width - insets.right - maxSize.width);
		} else {
			leftMin = Math.max(leftMin, paneSize.height - insets.bottom - maxSize.height);
		}
		/*
		 * To avoid inconsistency with the maximum location, it would seem
		 * reasonable to do:
		 *
		 *	leftMin = Math.min(leftMin, getMaximumDividerLocation(pane));
		 *
		 * however, the parent already calls getMinimumDividerLocation()
		 * in getMaximumDividerLocation(), so that would be a good way
		 * to get a stack overflow.
		 */
	}
	return leftMin;
}
 
Example 3
Source File: JSplitPaneSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Removes a real component from a real container.
    * @param container instance of a real container
    * @param containerDelegate effective container delegate of the container
    * @param component component to be removed
    * @return whether it was possible to remove the component (some containers
    *         may not support removing individual components reasonably)
    */
   @Override
   public boolean removeComponentFromContainer(Container container,
                                               Container containerDelegate,
                                               Component component)
   {
if( !(containerDelegate instanceof JSplitPane) ) {
    return false; // should not happen
}	

JSplitPane splitPane = (JSplitPane) containerDelegate;

if( component == splitPane.getLeftComponent() ) { 
    if( super.removeComponentFromContainer(container, containerDelegate, component) ) {
	JButton left = (JButton) splitPane.getClientProperty(LEFT_TOP_BUTTON);
	if( left != null ) {
	    // fall back to the default swing setting
	    splitPane.setLeftComponent(left);
	    splitPane.putClientProperty(LEFT_TOP_BUTTON, null);
	}	
	return true;
    }
} else if ( component == splitPane.getRightComponent() ) {    
    if( super.removeComponentFromContainer(container, containerDelegate, component) ) {
	JButton right = (JButton) splitPane.getClientProperty(RIGHT_BOTTOM_BUTTON);
	if( right != null ) {
	    // fall back to the default swing setting		    
	    splitPane.setRightComponent(right);		    
	    splitPane.putClientProperty(RIGHT_BOTTOM_BUTTON, null);
	}	
	return true;
    }
}

       return super.removeComponentFromContainer(container, containerDelegate, component);
   }
 
Example 4
Source File: JCompoundSplitPane.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Component getSecondComponent(JSplitPane splitPane) {
    if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        return splitPane.getRightComponent();
    } else {
        return splitPane.getBottomComponent();
    }
}
 
Example 5
Source File: JCompoundSplitPane.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private Component getSecondComponent(JSplitPane splitPane) {
    if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        return splitPane.getRightComponent();
    } else {
        return splitPane.getBottomComponent();
    }
}
 
Example 6
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private JTree getTree(TabData tabData){
    if(tabData==null){
        return null;
    }
    JSplitPane selSplitPane = (JSplitPane)tabData.getComponent();
    JSplitPane rightSplitPane = (JSplitPane)selSplitPane.getRightComponent();
    JScrollPane sp = (JScrollPane)rightSplitPane.getLeftComponent();
    JViewport vp = (JViewport)sp.getComponent(0);
    JTree t = (JTree)vp.getComponent(0);
    return t;
}
 
Example 7
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private JTable getTable(int tabIndex){
    if(tabIndex >= 0){
        TabData selTabData = tabDataModel.getTab(tabIndex);
        JSplitPane selSplitPane = (JSplitPane)selTabData.getComponent();
        JSplitPane rightSplitPane = (JSplitPane)selSplitPane.getRightComponent();
        JScrollPane sp = (JScrollPane)rightSplitPane.getRightComponent();
        JViewport vp = (JViewport)sp.getComponent(0);
        JTable t = (JTable)vp.getComponent(0);
        return t;
    }
    return null;
}