⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basicsplitpaneui.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    }    /**     * 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;    }    /**     * 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 new PropertyHandler();    }    /**     * Creates a FocusListener for the JSplitPane UI.     */    protected FocusListener createFocusListener() {        return new FocusHandler();    }    /**     * 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.     */    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.     */    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.     */    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.     */    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.     */    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 inner class is marked &quot;public&quot; due to a compiler bug.     * This class should be treated as a &quot;protected&quot; inner class.     * Instantiate it only within subclasses of BasicSplitPaneUI.     */    public class PropertyHandler implements PropertyChangeListener    {        /**         * 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) {            if(e.getSource() == splitPane) {                String changeName = e.getPropertyName();                if(changeName.equals(JSplitPane.ORIENTATION_PROPERTY)) {                    orientation = splitPane.getOrientation();                    resetLayoutManager();                } else if(changeName.equals(                                    JSplitPane.CONTINUOUS_LAYOUT_PROPERTY)) {                    setContinuousLayout(splitPane.isContinuousLayout());                    if(!isContinuousLayout()) {                        if(nonContinuousLayoutDivider == null) {                            setNonContinuousLayoutDivider(                                createDefaultNonContinuousLayoutDivider(),                                true);                        } else if(nonContinuousLayoutDivider.getParent() ==                                  null) {                            setNonContinuousLayoutDivider(                                nonContinuousLayoutDivider,                                true);                        }                    }                } else if(changeName.equals(JSplitPane.DIVIDER_SIZE_PROPERTY)){                    divider.setDividerSize(splitPane.getDividerSize());		    dividerSize = divider.getDividerSize();                    splitPane.revalidate();		    splitPane.repaint();                }            }        }    }    /**     * Implementation of the FocusListener that the JSplitPane UI uses.     * <p>     * This inner class is marked &quot;public&quot; due to a compiler bug.     * This class should be treated as a &quot;protected&quot; inner class.     * Instantiate it only within subclasses of BasicSplitPaneUI.     */    public class FocusHandler extends FocusAdapter    {        public void focusGained(FocusEvent ev) {            dividerKeyboardResize = true;            splitPane.repaint();        }        public void focusLost(FocusEvent ev) {            dividerKeyboardResize = false;            splitPane.repaint();        }    }        /**     * Implementation of an ActionListener that the JSplitPane UI uses for     * handling specific key presses.     * <p>     * This inner class is marked &quot;public&quot; due to a compiler bug.     * This class should be treated as a &quot;protected&quot; 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()));            }        }    }    static class KeyboardUpLeftAction extends AbstractAction {        public void actionPerformed(ActionEvent ev) {	    JSplitPane splitPane = (JSplitPane)ev.getSource();	    BasicSplitPaneUI ui = (BasicSplitPaneUI)splitPane.getUI();            if (ui.dividerKeyboardResize) {		splitPane.setDividerLocation(Math.max(0,ui.getDividerLocation				  (splitPane) - ui.getKeyboardMoveIncrement()));            }        }    }    /**     * Implementation of an ActionListener that the JSplitPane UI uses for     * handling specific key presses.     * <p>     * This inner class is marked &quot;public&quot; due to a compiler bug.     * This class should be treated as a &quot;protected&quot; 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());            }        }    }    static class KeyboardDownRightAction extends AbstractAction {        public void actionPerformed(ActionEvent ev) {	    JSplitPane splitPane = (JSplitPane)ev.getSource();	    BasicSplitPaneUI ui = (BasicSplitPaneUI)splitPane.getUI();            if (ui.dividerKeyboardResize) {                splitPane.setDividerLocation(ui.getDividerLocation(splitPane) +					     ui.getKeyboardMoveIncrement());            }        }    }        /**     * Implementation of an ActionListener that the JSplitPane UI uses for     * handling specific key presses.     * <p>     * This inner class is marked &quot;public&quot; due to a compiler bug.     * This class should be treated as a &quot;protected&quot; inner class.     * Instantiate it only within subclasses of BasicSplitPaneUI.     */    public class KeyboardHomeHandler implements ActionListener    {        public void actionPerformed(ActionEvent ev) {            if (dividerKeyboardResize) {                splitPane.setDividerLocation(0);            }        }    }    static class KeyboardHomeAction extends AbstractAction {        public void actionPerformed(ActionEvent ev) {	    JSplitPane splitPane = (JSplitPane)ev.getSource();	    BasicSplitPaneUI ui = (BasicSplitPaneUI)splitPane.getUI();            if (ui.dividerKeyboardResize) {                splitPane.setDividerLocation(0);            }        }    }        /**     * Implementation of an ActionListener that the JSplitPane UI uses for     * handling specific key presses.     * <p>     * This inner class is marked &quot;public&quot; due to a compiler bug.     * This class should be treated as a &quot;protected&quot; 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 {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -