?? basicsplitpaneui.java
字號:
splitPane = null; } /** * Uninstalls the UI defaults. */ protected void uninstallDefaults() { if(splitPane.getLayout() == layoutManager) { splitPane.setLayout(null); } if(nonContinuousLayoutDivider != null) { splitPane.remove(nonContinuousLayoutDivider); } LookAndFeel.uninstallBorder(splitPane); Border b = divider.getBorder(); if (b instanceof UIResource) { divider.setBorder(null); } splitPane.remove(divider); divider.setBasicSplitPaneUI(null); layoutManager = null; divider = null; nonContinuousLayoutDivider = null; setNonContinuousLayoutDivider(null); // sets the focus forward and backward traversal keys to null // to restore the defaults splitPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null); splitPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null); } /** * Uninstalls the event listeners for the UI. */ protected void uninstallListeners() { if (propertyChangeListener != null) { splitPane.removePropertyChangeListener(propertyChangeListener); propertyChangeListener = null; } if (focusListener != null) { splitPane.removeFocusListener(focusListener); focusListener = null; } keyboardUpLeftListener = null; keyboardDownRightListener = null; keyboardHomeListener = null; keyboardEndListener = null; keyboardResizeToggleListener = null; handler = null; } /** * Uninstalls the keyboard actions for the UI. */ protected void uninstallKeyboardActions() { SwingUtilities.replaceUIActionMap(splitPane, null); SwingUtilities.replaceUIInputMap(splitPane, JComponent. WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); } /** * Creates a PropertyChangeListener for the JSplitPane UI. */ protected PropertyChangeListener createPropertyChangeListener() { return getHandler(); } private Handler getHandler() { if (handler == null) { handler = new Handler(); } return handler; } /** * Creates a FocusListener for the JSplitPane UI. */ protected FocusListener createFocusListener() { return getHandler(); } /** * As of Java 2 platform v1.3 this method is no * longer used. Subclassers previously using this method should * instead create an Action wrapping the ActionListener, and register * that Action by overriding <code>installKeyboardActions</code> and * placing the Action in the SplitPane's ActionMap. Please refer to * the key bindings specification for further details. * <p> * Creates a ActionListener for the JSplitPane UI that listens for * specific key presses. * * @deprecated As of Java 2 platform v1.3. */ @Deprecated protected ActionListener createKeyboardUpLeftListener() { return new KeyboardUpLeftHandler(); } /** * As of Java 2 platform v1.3 this method is no * longer used. Subclassers previously using this method should * instead create an Action wrapping the ActionListener, and register * that Action by overriding <code>installKeyboardActions</code> and * placing the Action in the SplitPane's ActionMap. Please refer to * the key bindings specification for further details. * <p> * Creates a ActionListener for the JSplitPane UI that listens for * specific key presses. * * @deprecated As of Java 2 platform v1.3. */ @Deprecated protected ActionListener createKeyboardDownRightListener() { return new KeyboardDownRightHandler(); } /** * As of Java 2 platform v1.3 this method is no * longer used. Subclassers previously using this method should * instead create an Action wrapping the ActionListener, and register * that Action by overriding <code>installKeyboardActions</code> and * placing the Action in the SplitPane's ActionMap. Please refer to * the key bindings specification for further details. * <p> * Creates a ActionListener for the JSplitPane UI that listens for * specific key presses. * * @deprecated As of Java 2 platform v1.3. */ @Deprecated protected ActionListener createKeyboardHomeListener() { return new KeyboardHomeHandler(); } /** * As of Java 2 platform v1.3 this method is no * longer used. Subclassers previously using this method should * instead create an Action wrapping the ActionListener, and register * that Action by overriding <code>installKeyboardActions</code> and * placing the Action in the SplitPane's ActionMap. Please refer to * the key bindings specification for further details. * <p> * Creates a ActionListener for the JSplitPane UI that listens for * specific key presses. * * @deprecated As of Java 2 platform v1.3. */ @Deprecated protected ActionListener createKeyboardEndListener() { return new KeyboardEndHandler(); } /** * As of Java 2 platform v1.3 this method is no * longer used. Subclassers previously using this method should * instead create an Action wrapping the ActionListener, and register * that Action by overriding <code>installKeyboardActions</code> and * placing the Action in the SplitPane's ActionMap. Please refer to * the key bindings specification for further details. * <p> * Creates a ActionListener for the JSplitPane UI that listens for * specific key presses. * * @deprecated As of Java 2 platform v1.3. */ @Deprecated protected ActionListener createKeyboardResizeToggleListener() { return new KeyboardResizeToggleHandler(); } /** * Returns the orientation for the JSplitPane. */ public int getOrientation() { return orientation; } /** * Set the orientation for the JSplitPane. */ public void setOrientation(int orientation) { this.orientation = orientation; } /** * Determines wether the JSplitPane is set to use a continuous layout. */ public boolean isContinuousLayout() { return continuousLayout; } /** * Turn continuous layout on/off. */ public void setContinuousLayout(boolean b) { continuousLayout = b; } /** * Returns the last drag location of the JSplitPane. */ public int getLastDragLocation() { return lastDragLocation; } /** * Set the last drag location of the JSplitPane. */ public void setLastDragLocation(int l) { lastDragLocation = l; } /** * @return increment via keyboard methods. */ int getKeyboardMoveIncrement() { return KEYBOARD_DIVIDER_MOVE_OFFSET; } /** * Implementation of the PropertyChangeListener * that the JSplitPane UI uses. * <p> * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. */ public class PropertyHandler implements PropertyChangeListener { // NOTE: This class exists only for backward compatability. All // its functionality has been moved into Handler. If you need to add // new functionality add it to the Handler, but make sure this // class calls into the Handler. /** * Messaged from the <code>JSplitPane</code> the receiver is * contained in. May potentially reset the layout manager and cause a * <code>validate</code> to be sent. */ public void propertyChange(PropertyChangeEvent e) { getHandler().propertyChange(e); } } /** * Implementation of the FocusListener that the JSplitPane UI uses. * <p> * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. */ public class FocusHandler extends FocusAdapter { // NOTE: This class exists only for backward compatability. All // its functionality has been moved into Handler. If you need to add // new functionality add it to the Handler, but make sure this // class calls into the Handler. public void focusGained(FocusEvent ev) { getHandler().focusGained(ev); } public void focusLost(FocusEvent ev) { getHandler().focusLost(ev); } } /** * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * <p> * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. */ public class KeyboardUpLeftHandler implements ActionListener { public void actionPerformed(ActionEvent ev) { if (dividerKeyboardResize) { splitPane.setDividerLocation(Math.max(0,getDividerLocation (splitPane) - getKeyboardMoveIncrement())); } } } /** * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * <p> * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. */ public class KeyboardDownRightHandler implements ActionListener { public void actionPerformed(ActionEvent ev) { if (dividerKeyboardResize) { splitPane.setDividerLocation(getDividerLocation(splitPane) + getKeyboardMoveIncrement()); } } } /** * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * <p> * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. */ public class KeyboardHomeHandler implements ActionListener { public void actionPerformed(ActionEvent ev) { if (dividerKeyboardResize) { splitPane.setDividerLocation(0); } } } /** * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * <p> * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. */ public class KeyboardEndHandler implements ActionListener { public void actionPerformed(ActionEvent ev) { if (dividerKeyboardResize) { Insets insets = splitPane.getInsets(); int bottomI = (insets != null) ? insets.bottom : 0; int rightI = (insets != null) ? insets.right : 0; if (orientation == JSplitPane.VERTICAL_SPLIT) { splitPane.setDividerLocation(splitPane.getHeight() - bottomI); } else { splitPane.setDividerLocation(splitPane.getWidth() - rightI); } } } } /** * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * <p> * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. */ public class KeyboardResizeToggleHandler implements ActionListener { public void actionPerformed(ActionEvent ev) { if (!dividerKeyboardResize) { splitPane.requestFocus(); } } } /** * Returns the divider between the top Components. */ public BasicSplitPaneDivider getDivider() { return divider; } /** * Returns the default non continuous layout divider, which is an * instanceof Canvas that fills the background in dark gray. */ protected Component createDefaultNonContinuousLayoutDivider() { return new Canvas() { public void paint(Graphics g) { if(!isContinuousLayout() && getLastDragLocation() != -1) { Dimension size = splitPane.getSize(); g.setColor(dividerDraggingColor); if(orientation == JSplitPane.HORIZONTAL_SPLIT) { g.fillRect(0, 0, dividerSize - 1, size.height - 1); } else { g.fillRect(0, 0, size.width - 1, dividerSize - 1); } } } }; }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -