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

The following examples show how to use javax.swing.JSplitPane#getLeftComponent() . 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 getMaximumDividerLocation(JSplitPane pane) {
	int rightMax = super.getMaximumDividerLocation(pane);
	Component first = pane.getLeftComponent();
	if ((first != null) && first.isVisible()) {
		Dimension maxSize = first.getMaximumSize();
		Insets insets = pane.getInsets();
		if (pane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
			rightMax = Math.min(rightMax, maxSize.width + insets.left);
		} else {
			rightMax = Math.min(rightMax, maxSize.height + insets.top);
		}
		// Sanity check. Must be in this method, not in
		// getMinimumDividerLocation() (see below)
		rightMax = Math.max(rightMax, getMinimumDividerLocation(pane));
	}

	return rightMax;
}
 
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 getFirstComponent(JSplitPane splitPane) {
    if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        return splitPane.getLeftComponent();
    } else {
        return splitPane.getTopComponent();
    }
}
 
Example 5
Source File: ResultWindow.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override boolean requestFocusInWindow() {
    JSplitPane view = getCurrentResultView();
    if (view == null) {
        return super.requestFocusInWindow();
    }
    Component left = view.getLeftComponent();
    if (left == null) {
        return super.requestFocusInWindow();
    }
    return left.requestFocusInWindow();
}
 
Example 6
Source File: ResultWindow.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    JSplitPane view = getCurrentResultView();
    if (view == null || !(view.getLeftComponent() instanceof StatisticsPanel)) {
        return;
    }
    StatisticsPanel statisticsPanel = (StatisticsPanel) view.getLeftComponent();
    if (next) {
        statisticsPanel.selectNextFailure();
    } else {
        statisticsPanel.selectPreviousFailure();
    }
}
 
Example 7
Source File: ResultWindow.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static StatisticsPanel getStatisticsPanel() {
JSplitPane view = getCurrentResultView();
if (view == null || !(view.getLeftComponent() instanceof StatisticsPanel)) {
    return null;
}
return (StatisticsPanel) view.getLeftComponent();
   }
 
Example 8
Source File: JCompoundSplitPane.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private Component getFirstComponent(JSplitPane splitPane) {
    if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        return splitPane.getLeftComponent();
    } else {
        return splitPane.getTopComponent();
    }
}
 
Example 9
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private JTextArea getTextArea(){
    int selIndex = getTabIndex();
    if(selIndex >= 0){
        TabData selTabData = tabDataModel.getTab(selIndex);
        JSplitPane selSplitPane = (JSplitPane)selTabData.getComponent();
        JScrollPane sp = (JScrollPane)selSplitPane.getLeftComponent();
        JViewport vp = (JViewport)sp.getComponent(0);
        JTextArea ta = (JTextArea)vp.getComponent(0);
        return ta;
    }
    return null;
}
 
Example 10
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 11
Source File: ResultWindow.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void copyFilterMask(JSplitPane oldView, JSplitPane newView) {
    StatisticsPanel oldSP = (StatisticsPanel)oldView.getLeftComponent();
    StatisticsPanel newSP = (StatisticsPanel)newView.getLeftComponent();
    newSP.copyFilterMask(oldSP);
}