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

📄 basicsplitpaneui.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * @(#)BasicSplitPaneUI.java	1.73 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package javax.swing.plaf.basic;import javax.swing.*;import javax.swing.border.Border;import javax.swing.event.*;import java.awt.*;import java.awt.event.*;import java.awt.peer.ComponentPeer;import java.awt.peer.LightweightPeer;import java.beans.*;import java.util.*;import javax.swing.plaf.ActionMapUIResource;import javax.swing.plaf.SplitPaneUI;import javax.swing.plaf.ComponentUI;import javax.swing.plaf.UIResource;/** * A Basic L&F implementation of the SplitPaneUI. * * @version 1.73 01/23/03 * @author Scott Violet * @author Steve Wilson * @author Ralph Kar */public class BasicSplitPaneUI extends SplitPaneUI{    /**     * The divider used for non-continuous layout is added to the split pane     * with this object.     */    protected static final String NON_CONTINUOUS_DIVIDER =        "nonContinuousDivider";    /**     * How far (relativ) the divider does move when it is moved around by     * the cursor keys on the keyboard.     */    protected static int KEYBOARD_DIVIDER_MOVE_OFFSET = 3;    /**     * JSplitPane instance this instance is providing     * the look and feel for.     */    protected JSplitPane splitPane;    /**     * LayoutManager that is created and placed into the split pane.     */    protected BasicHorizontalLayoutManager layoutManager;    /**     * Instance of the divider for this JSplitPane.     */    protected BasicSplitPaneDivider divider;    /**     * Instance of the PropertyChangeListener for this JSplitPane.     */    protected PropertyChangeListener propertyChangeListener;    /**     * Instance of the FocusListener for this JSplitPane.     */    protected FocusListener focusListener;    /**     * Keys to use for forward focus traversal when the JComponent is     * managing focus.     */    private static Set managingFocusForwardTraversalKeys;    /**     * Keys to use for backward focus traversal when the JComponent is     * managing focus.     */    private static Set managingFocusBackwardTraversalKeys;    /**     * The size of the divider while the dragging session is valid.     */    protected int dividerSize;    /**     * Instance for the shadow of the divider when non continuous layout     * is being used.     */    protected Component nonContinuousLayoutDivider;    /**     * Set to true in startDragging if any of the children     * (not including the nonContinuousLayoutDivider) are heavy weights.     */    protected boolean draggingHW;    /**     * Location of the divider when the dragging session began.     */    protected int beginDragDividerLocation;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected KeyStroke upKey;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected KeyStroke downKey;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected KeyStroke leftKey;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected KeyStroke rightKey;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected KeyStroke homeKey;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected KeyStroke endKey;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected KeyStroke dividerResizeToggleKey;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected ActionListener keyboardUpLeftListener;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected ActionListener keyboardDownRightListener;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected ActionListener keyboardHomeListener;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected ActionListener keyboardEndListener;    /**     * As of Java 2 platform v1.3 this previously undocumented field is no     * longer used.     * Key bindings are now defined by the LookAndFeel, please refer to     * the key bindings specification for further details.     *     * @deprecated As of Java 2 platform v1.3.     */    protected ActionListener keyboardResizeToggleListener;    // Private data of the instance    private int         orientation;    private int         lastDragLocation;    private boolean     continuousLayout;    private boolean     dividerKeyboardResize;    private boolean     dividerLocationIsSet;  // needed for tracking                                               // the first occurrence of                                               // setDividerLocation()    private boolean rememberPaneSizes;    /** Indicates that we have painted once. */    // This is used by the LayoutManger to determine when it should use    // the divider location provided by the JSplitPane. This is used as there    // is no way to determine when the layout process has completed.    boolean             painted;    /** If true, setDividerLocation does nothing. */    boolean             ignoreDividerLocationChange;    /**     * Creates a new BasicSplitPaneUI instance     */    public static ComponentUI createUI(JComponent x) {        return new BasicSplitPaneUI();    }    /**     * Installs the UI.     */    public void installUI(JComponent c) {        splitPane = (JSplitPane) c;        dividerLocationIsSet = false;        dividerKeyboardResize = false;        installDefaults();        installListeners();        installKeyboardActions();        setLastDragLocation(-1);    }    /**     * Installs the UI defaults.     */    protected void installDefaults(){         LookAndFeel.installBorder(splitPane, "SplitPane.border");        LookAndFeel.installColors(splitPane, "SplitPane.background",                                  "SplitPane.foreground");        if (divider == null) divider = createDefaultDivider();        divider.setBasicSplitPaneUI(this);	Border    b = divider.getBorder();	if (b == null || !(b instanceof UIResource)) {	    divider.setBorder(UIManager.getBorder("SplitPaneDivider.border"));	}        setOrientation(splitPane.getOrientation());	// This plus 2 here is to provide backwards consistancy. Previously,	// the old size did not include the 2 pixel border around the divider,	// it now does.        splitPane.setDividerSize(((Integer) (UIManager.get(            "SplitPane.dividerSize"))).intValue());        divider.setDividerSize(splitPane.getDividerSize());	dividerSize = divider.getDividerSize();        splitPane.add(divider, JSplitPane.DIVIDER);        setContinuousLayout(splitPane.isContinuousLayout());        resetLayoutManager();        /* Install the nonContinuousLayoutDivider here to avoid having to        add/remove everything later. */        if(nonContinuousLayoutDivider == null) {            setNonContinuousLayoutDivider(                                createDefaultNonContinuousLayoutDivider(),                                true);        } else {            setNonContinuousLayoutDivider(nonContinuousLayoutDivider, true);        }	// focus forward traversal key	if (managingFocusForwardTraversalKeys==null) {	    managingFocusForwardTraversalKeys = new TreeSet();	    managingFocusForwardTraversalKeys.add(		KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));	}	splitPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,					managingFocusForwardTraversalKeys);	// focus backward traversal key	if (managingFocusBackwardTraversalKeys==null) {	    managingFocusBackwardTraversalKeys = new TreeSet();	    managingFocusBackwardTraversalKeys.add(		KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));	}	splitPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,					managingFocusBackwardTraversalKeys);    }    /**     * Installs the event listeners for the UI.     */    protected void installListeners() {        if ((propertyChangeListener = createPropertyChangeListener()) !=            null) {            splitPane.addPropertyChangeListener(propertyChangeListener);        }        if ((focusListener = createFocusListener()) != null) {            splitPane.addFocusListener(focusListener);        }    }    /**     * Installs the keyboard actions for the UI.     */    protected void installKeyboardActions() {	InputMap km = getInputMap(JComponent.				  WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);	SwingUtilities.replaceUIInputMap(splitPane, JComponent.				       WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,				       km);	ActionMap am = getActionMap();	SwingUtilities.replaceUIActionMap(splitPane, am);    }    InputMap getInputMap(int condition) {	if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {	    return (InputMap)UIManager.get("SplitPane.ancestorInputMap");	}	return null;    }    ActionMap getActionMap() {	ActionMap map = (ActionMap)UIManager.get("SplitPane.actionMap");	if (map == null) {	    map = createActionMap();	    if (map != null) {		UIManager.getLookAndFeelDefaults().put("SplitPane.actionMap",                                                       map);	    }	}	return map;    }    ActionMap createActionMap() {	ActionMap map = new ActionMapUIResource();        map.put("negativeIncrement", new KeyboardUpLeftAction());	map.put("positiveIncrement", new KeyboardDownRightAction());	map.put("selectMin", new KeyboardHomeAction());	map.put("selectMax", new KeyboardEndAction());	map.put("startResize", new KeyboardResizeToggleAction());	map.put("toggleFocus", new ToggleSideFocusAction());	map.put("focusOutForward", new MoveFocusOutAction(1));	map.put("focusOutBackward", new MoveFocusOutAction(-1));	return map;    }    /**     * Uninstalls the UI.     */    public void uninstallUI(JComponent c) {        uninstallKeyboardActions();        uninstallListeners();        uninstallDefaults();        dividerLocationIsSet = false;        dividerKeyboardResize = false;        splitPane = null;

⌨️ 快捷键说明

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