Java Code Examples for javax.swing.plaf.basic.BasicSplitPaneUI

The following examples show how to use javax.swing.plaf.basic.BasicSplitPaneUI. These examples are extracted from open source projects. 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 Project: java-swing-tips   Source File: MainPanel.java    License: MIT License 6 votes vote down vote up
private MainPanel() {
  super(new GridLayout(2, 1));

  JSplitPane splitPane = new JSplitPane();
  Container divider = ((BasicSplitPaneUI) splitPane.getUI()).getDivider();
  divider.addMouseListener(new MouseAdapter() {
    @Override public void mousePressed(MouseEvent e) {
      super.mousePressed(e);
      splitPane.requestFocusInWindow();
      // or
      // Action startResize = splitPane.getActionMap().get("startResize");
      // startResize.actionPerformed(new ActionEvent(splitPane, ActionEvent.ACTION_PERFORMED, "startResize"));
    }
  });

  add(makeTitledPanel("Default", new JSplitPane()));
  add(makeTitledPanel("Divider.addMouseListener", splitPane));
  setPreferredSize(new Dimension(320, 240));
}
 
Example 2
Source Project: netbeans   Source File: DiffSplitPaneDivider.java    License: Apache License 2.0 6 votes vote down vote up
DiffSplitPaneDivider(BasicSplitPaneUI splitPaneUI, EditableDiffView master) {
    super(splitPaneUI);
    this.master = master;
    fontColor = new JLabel().getForeground();

    actionIconsHeight = insertAllImage.getHeight(this);
    actionIconsWidth = insertAllImage.getWidth(this);
    
    setBorder(null);
    setLayout(new BorderLayout());
    mydivider = new DiffSplitDivider();
    add(mydivider);
    
    addMouseListener(this);
    addMouseMotionListener(this);
}
 
Example 3
Source Project: org.alloytools.alloy   Source File: OurUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new SplitPane containing the two components given as arguments
 *
 * @param orientation - the orientation (HORIZONTAL_SPLIT or VERTICAL_SPLIT)
 * @param first - the left component (if horizontal) or top component (if
 *            vertical)
 * @param second - the right component (if horizontal) or bottom component (if
 *            vertical)
 * @param initialDividerLocation - the initial divider location (in pixels)
 */
public static JSplitPane splitpane(int orientation, Component first, Component second, int initialDividerLocation) {
    JSplitPane x = make(new JSplitPane(orientation, first, second), new EmptyBorder(0, 0, 0, 0));
    x.setContinuousLayout(true);
    x.setDividerLocation(initialDividerLocation);
    x.setOneTouchExpandable(false);
    x.setResizeWeight(0.5);
    if (Util.onMac() && (x.getUI() instanceof BasicSplitPaneUI)) {
        boolean h = (orientation != JSplitPane.HORIZONTAL_SPLIT);
        ((BasicSplitPaneUI) (x.getUI())).getDivider().setBorder(new OurBorder(h, h, h, h)); // Makes
                                                                                           // the
                                                                                           // border
                                                                                           // look
                                                                                           // nicer
                                                                                           // on
                                                                                           // Mac
                                                                                           // OS
                                                                                           // X
    }
    return x;
}
 
Example 4
protected JComponent createComponent() {
    final JComponent comp = super.createComponent();
    
    if (toolbar == null) init();
    
    JExtendedSplitPane contentSplit = new JExtendedSplitPane(JExtendedSplitPane.VERTICAL_SPLIT, true, comp, pluginsComponent) {
        public boolean requestFocusInWindow() {
            return comp.requestFocusInWindow();
        }
    };
    BasicSplitPaneDivider contentDivider = ((BasicSplitPaneUI)contentSplit.getUI()).getDivider();
    contentDivider.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, SEPARATOR_COLOR));
    contentDivider.setDividerSize(5);
    contentSplit.setBorder(BorderFactory.createEmptyBorder());
    contentSplit.setResizeWeight(0.7d);
    
    return contentSplit;
}
 
Example 5
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 6
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 7
/**
 * Sets the SplitPaneUI that is using the receiver. This is completely
 * overriden from super to create a different MouseHandler.
 */
public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
    if (splitPane != null) {
        splitPane.removePropertyChangeListener(this);
       if (mouseHandler != null) {
           splitPane.removeMouseListener(mouseHandler);
           splitPane.removeMouseMotionListener(mouseHandler);
           removeMouseListener(mouseHandler);
           removeMouseMotionListener(mouseHandler);
           mouseHandler = null;
       }
    }
    splitPaneUI = newUI;
    if (newUI != null) {
        splitPane = newUI.getSplitPane();
        if (splitPane != null) {
            if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
            splitPane.addMouseListener(mouseHandler);
            splitPane.addMouseMotionListener(mouseHandler);
            addMouseListener(mouseHandler);
            addMouseMotionListener(mouseHandler);
            splitPane.addPropertyChangeListener(this);
            if (splitPane.isOneTouchExpandable()) {
                oneTouchExpandableChanged();
            }
        }
    }
    else {
        splitPane = null;
    }
}
 
Example 8
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 9
/**
 * Sets the SplitPaneUI that is using the receiver. This is completely
 * overriden from super to create a different MouseHandler.
 */
public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
    if (splitPane != null) {
        splitPane.removePropertyChangeListener(this);
       if (mouseHandler != null) {
           splitPane.removeMouseListener(mouseHandler);
           splitPane.removeMouseMotionListener(mouseHandler);
           removeMouseListener(mouseHandler);
           removeMouseMotionListener(mouseHandler);
           mouseHandler = null;
       }
    }
    splitPaneUI = newUI;
    if (newUI != null) {
        splitPane = newUI.getSplitPane();
        if (splitPane != null) {
            if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
            splitPane.addMouseListener(mouseHandler);
            splitPane.addMouseMotionListener(mouseHandler);
            addMouseListener(mouseHandler);
            addMouseMotionListener(mouseHandler);
            splitPane.addPropertyChangeListener(this);
            if (splitPane.isOneTouchExpandable()) {
                oneTouchExpandableChanged();
            }
        }
    }
    else {
        splitPane = null;
    }
}
 
Example 10
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 11
/**
 * {@code setupExtensions} installs the mouse listener for the popup menu,
 * and fixes some egregious defaults in {@code JSplitPane}.
 */
private void setupExtensions()
{
	SplitPaneUI anUi = getUI();

	if (anUi instanceof BasicSplitPaneUI)
	{
		((BasicSplitPaneUI) anUi).getDivider().addMouseListener(new PopupListener());
	}
	setResizeWeight(0.5);
}
 
Example 12
Source Project: JDKSourceCode1.8   Source File: MotifSplitPaneDivider.java    License: MIT License 5 votes vote down vote up
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 13
Source Project: JDKSourceCode1.8   Source File: MotifSplitPaneDivider.java    License: MIT License 5 votes vote down vote up
/**
 * Sets the SplitPaneUI that is using the receiver. This is completely
 * overriden from super to create a different MouseHandler.
 */
public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
    if (splitPane != null) {
        splitPane.removePropertyChangeListener(this);
       if (mouseHandler != null) {
           splitPane.removeMouseListener(mouseHandler);
           splitPane.removeMouseMotionListener(mouseHandler);
           removeMouseListener(mouseHandler);
           removeMouseMotionListener(mouseHandler);
           mouseHandler = null;
       }
    }
    splitPaneUI = newUI;
    if (newUI != null) {
        splitPane = newUI.getSplitPane();
        if (splitPane != null) {
            if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
            splitPane.addMouseListener(mouseHandler);
            splitPane.addMouseMotionListener(mouseHandler);
            addMouseListener(mouseHandler);
            addMouseMotionListener(mouseHandler);
            splitPane.addPropertyChangeListener(this);
            if (splitPane.isOneTouchExpandable()) {
                oneTouchExpandableChanged();
            }
        }
    }
    else {
        splitPane = null;
    }
}
 
Example 14
Source Project: Data_Processor   Source File: UnicornJSplitPane.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void layout() {
	super.layout();
	BasicSplitPaneDivider divider = ((BasicSplitPaneUI)getUI()).getDivider();
	Rectangle bounds = divider.getBounds();
	if( orientation == HORIZONTAL_SPLIT ) {
		bounds.x -= dividerDragOffset;
		bounds.width = dividerDragSize;
	} else {
		bounds.y -= dividerDragOffset;
		bounds.height = dividerDragSize;
	}
	divider.setBounds(bounds);
}
 
Example 15
Source Project: seaglass   Source File: SeaGlassSplitPaneDivider.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new SeaGlassSplitPaneDivider object.
 *
 * @param ui the parent UI delegate.
 */
public SeaGlassSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    oneTouchSize          = DefaultLookup.getInt(ui.getSplitPane(), ui, "SplitPane.oneTouchButtonSize", ONE_TOUCH_SIZE);
    oneTouchOffset        = DefaultLookup.getInt(ui.getSplitPane(), ui, "SplitPane.oneTouchButtonOffset", ONE_TOUCH_OFFSET);
    centerOneTouchButtons = DefaultLookup.getBoolean(ui.getSplitPane(), ui, "SplitPane.centerOneTouchButtons", true);
    oneTouchVOffset       = DefaultLookup.getInt(ui.getSplitPane(), ui, "SplitPane.oneTouchButtonVOffset", 0);
    setLayout(new DividerLayout());
}
 
Example 16
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 17
Source Project: netbeans   Source File: InstancesControllerUI.java    License: Apache License 2.0 5 votes vote down vote up
private void tweakSplitPaneUI(JSplitPane splitPane) {
    splitPane.setOpaque(false);
    splitPane.setBorder(null);
    splitPane.setDividerSize(3);

    if (!(splitPane.getUI() instanceof BasicSplitPaneUI)) {
        return;
    }

    BasicSplitPaneDivider divider = ((BasicSplitPaneUI) splitPane.getUI()).getDivider();

    if (divider != null) {
        divider.setBorder(null);
    }
}
 
Example 18
Source Project: netbeans   Source File: SummaryControllerUI.java    License: Apache License 2.0 5 votes vote down vote up
private void tweakSplitPaneUI(JSplitPane splitPane) {
    splitPane.setOpaque(false);
    splitPane.setBorder(null);
    splitPane.setDividerSize(3);

    if (!(splitPane.getUI() instanceof BasicSplitPaneUI)) {
        return;
    }

    BasicSplitPaneDivider divider = ((BasicSplitPaneUI) splitPane.getUI()).getDivider();

    if (divider != null) {
        divider.setBorder(null);
    }
}
 
Example 19
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 20
Source Project: netbeans   Source File: PaneBuilders.java    License: Apache License 2.0 5 votes vote down vote up
protected BasicSplitPaneDivider createInstanceImpl() {
    final JSplitPane split = new JSplitPane(orientation);
    BasicSplitPaneUI ui = split.getUI() instanceof BasicSplitPaneUI ?
            (BasicSplitPaneUI)split.getUI() : new BasicSplitPaneUI() {
                { installUI(split); }
            };
    return new BasicSplitPaneDivider(ui);
}
 
Example 21
Source Project: netbeans   Source File: CombinedPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void tweakUI() {
    setBorder(null);
    setDividerSize(5);

    if (!(getUI() instanceof BasicSplitPaneUI)) return;

    BasicSplitPaneDivider divider = ((BasicSplitPaneUI)getUI()).getDivider();
    if (divider != null) {
        Color c = UIUtils.isNimbus() ? UIUtils.getDisabledLineColor() :
                new JSeparator().getForeground();
        divider.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, c));
    }
}
 
Example 22
Source Project: netbeans   Source File: JExtendedSplitPane.java    License: Apache License 2.0 5 votes vote down vote up
private Component getDivider() {
    if (getUI() == null) {
        return null;
    }

    return ((BasicSplitPaneUI) getUI()).getDivider();
}
 
Example 23
Source Project: netbeans   Source File: JCompoundSplitPane.java    License: Apache License 2.0 5 votes vote down vote up
private void tweakUI() {
    if (!(getUI() instanceof BasicSplitPaneUI)) {
        return;
    }

    BasicSplitPaneDivider divider = ((BasicSplitPaneUI) getUI()).getDivider();

    if (divider != null) {
        divider.addMouseListener(new DividerMouseListener());
    }
}
 
Example 24
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 25
/**
 * Sets the SplitPaneUI that is using the receiver. This is completely
 * overriden from super to create a different MouseHandler.
 */
public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
    if (splitPane != null) {
        splitPane.removePropertyChangeListener(this);
       if (mouseHandler != null) {
           splitPane.removeMouseListener(mouseHandler);
           splitPane.removeMouseMotionListener(mouseHandler);
           removeMouseListener(mouseHandler);
           removeMouseMotionListener(mouseHandler);
           mouseHandler = null;
       }
    }
    splitPaneUI = newUI;
    if (newUI != null) {
        splitPane = newUI.getSplitPane();
        if (splitPane != null) {
            if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
            splitPane.addMouseListener(mouseHandler);
            splitPane.addMouseMotionListener(mouseHandler);
            addMouseListener(mouseHandler);
            addMouseMotionListener(mouseHandler);
            splitPane.addPropertyChangeListener(this);
            if (splitPane.isOneTouchExpandable()) {
                oneTouchExpandableChanged();
            }
        }
    }
    else {
        splitPane = null;
    }
}
 
Example 26
Source Project: Bytecoder   Source File: MotifSplitPaneDivider.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 27
Source Project: Bytecoder   Source File: MotifSplitPaneDivider.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the SplitPaneUI that is using the receiver. This is completely
 * overriden from super to create a different MouseHandler.
 */
public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
    if (splitPane != null) {
        splitPane.removePropertyChangeListener(this);
       if (mouseHandler != null) {
           splitPane.removeMouseListener(mouseHandler);
           splitPane.removeMouseMotionListener(mouseHandler);
           removeMouseListener(mouseHandler);
           removeMouseMotionListener(mouseHandler);
           mouseHandler = null;
       }
    }
    splitPaneUI = newUI;
    if (newUI != null) {
        splitPane = newUI.getSplitPane();
        if (splitPane != null) {
            if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
            splitPane.addMouseListener(mouseHandler);
            splitPane.addMouseMotionListener(mouseHandler);
            addMouseListener(mouseHandler);
            addMouseMotionListener(mouseHandler);
            splitPane.addPropertyChangeListener(this);
            if (splitPane.isOneTouchExpandable()) {
                oneTouchExpandableChanged();
            }
        }
    }
    else {
        splitPane = null;
    }
}
 
Example 28
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 29
/**
 * Sets the SplitPaneUI that is using the receiver. This is completely
 * overriden from super to create a different MouseHandler.
 */
public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
    if (splitPane != null) {
        splitPane.removePropertyChangeListener(this);
       if (mouseHandler != null) {
           splitPane.removeMouseListener(mouseHandler);
           splitPane.removeMouseMotionListener(mouseHandler);
           removeMouseListener(mouseHandler);
           removeMouseMotionListener(mouseHandler);
           mouseHandler = null;
       }
    }
    splitPaneUI = newUI;
    if (newUI != null) {
        splitPane = newUI.getSplitPane();
        if (splitPane != null) {
            if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
            splitPane.addMouseListener(mouseHandler);
            splitPane.addMouseMotionListener(mouseHandler);
            addMouseListener(mouseHandler);
            addMouseMotionListener(mouseHandler);
            splitPane.addPropertyChangeListener(this);
            if (splitPane.isOneTouchExpandable()) {
                oneTouchExpandableChanged();
            }
        }
    }
    else {
        splitPane = null;
    }
}
 
Example 30
/**
 * Sets the SplitPaneUI that is using the receiver. This is completely
 * overriden from super to create a different MouseHandler.
 */
public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
    if (splitPane != null) {
        splitPane.removePropertyChangeListener(this);
       if (mouseHandler != null) {
           splitPane.removeMouseListener(mouseHandler);
           splitPane.removeMouseMotionListener(mouseHandler);
           removeMouseListener(mouseHandler);
           removeMouseMotionListener(mouseHandler);
           mouseHandler = null;
       }
    }
    splitPaneUI = newUI;
    if (newUI != null) {
        splitPane = newUI.getSplitPane();
        if (splitPane != null) {
            if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
            splitPane.addMouseListener(mouseHandler);
            splitPane.addMouseMotionListener(mouseHandler);
            addMouseListener(mouseHandler);
            addMouseMotionListener(mouseHandler);
            splitPane.addPropertyChangeListener(this);
            if (splitPane.isOneTouchExpandable()) {
                oneTouchExpandableChanged();
            }
        }
    }
    else {
        splitPane = null;
    }
}