BasicSplitPaneUI.java revision 0
4373N/A * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 4373N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4373N/A * This code is free software; you can redistribute it and/or modify it 4373N/A * under the terms of the GNU General Public License version 2 only, as 4373N/A * published by the Free Software Foundation. Sun designates this 4373N/A * particular file as subject to the "Classpath" exception as provided 4373N/A * by Sun in the LICENSE file that accompanied this code. 4373N/A * This code is distributed in the hope that it will be useful, but WITHOUT 4373N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4373N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4373N/A * version 2 for more details (a copy is included in the LICENSE file that 4373N/A * You should have received a copy of the GNU General Public License version 4373N/A * 2 along with this work; if not, write to the Free Software Foundation, 4373N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4373N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 4373N/A * CA 95054 USA or visit www.sun.com if you need additional information or 4373N/A * A Basic L&F implementation of the SplitPaneUI. 4373N/A * The divider used for non-continuous layout is added to the split pane 4373N/A * How far (relative) the divider does move when it is moved around by 4373N/A * the cursor keys on the keyboard. 4373N/A * JSplitPane instance this instance is providing 4373N/A * LayoutManager that is created and placed into the split pane. 4373N/A * Instance of the divider for this JSplitPane. 4373N/A * Instance of the PropertyChangeListener for this JSplitPane. 4373N/A * Instance of the FocusListener for this JSplitPane. 4373N/A * Keys to use for forward focus traversal when the JComponent is 4373N/A * Keys to use for backward focus traversal when the JComponent is 4373N/A * The size of the divider while the dragging session is valid. 4373N/A * Instance for the shadow of the divider when non continuous layout 4373N/A * Set to true in startDragging if any of the children 4373N/A * (not including the nonContinuousLayoutDivider) are heavy weights. * Location of the divider when the dragging session began. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. * As of Java 2 platform v1.3 this previously undocumented field is no * 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. // Private data of the instance // the first occurrence of // Indicates wether the one of splitpane sides is expanded /** Indicates that we have painted once. */ // This is used by the LayoutManager 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. /** If true, setDividerLocation does nothing. */ * Creates a new BasicSplitPaneUI instance * Installs the UI defaults. // This plus 2 here is to provide backwards consistancy. Previously, // the old size did not include the 2 pixel border around the divider, /* Install the nonContinuousLayoutDivider here to avoid having to // focus forward traversal key // focus backward traversal key * Installs the event listeners for the UI. * Installs the keyboard actions for the UI. "SplitPane.ancestorInputMap");
* Uninstalls the UI defaults. // sets the focus forward and backward traversal keys to null // to restore the defaults * Uninstalls the event listeners for the UI. * Uninstalls the keyboard actions for the UI. * Creates a PropertyChangeListener for the JSplitPane UI. * Creates a FocusListener for the JSplitPane UI. * 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. * Creates a ActionListener for the JSplitPane UI that listens for * @deprecated As of Java 2 platform v1.3. * 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. * Creates a ActionListener for the JSplitPane UI that listens for * @deprecated As of Java 2 platform v1.3. * 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. * Creates a ActionListener for the JSplitPane UI that listens for * @deprecated As of Java 2 platform v1.3. * 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. * Creates a ActionListener for the JSplitPane UI that listens for * @deprecated As of Java 2 platform v1.3. * 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. * Creates a ActionListener for the JSplitPane UI that listens for * @deprecated As of Java 2 platform v1.3. * Returns the orientation for the JSplitPane. * Set the orientation for the JSplitPane. * Determines wether the JSplitPane is set to use a continuous layout. * Turn continuous layout on/off. * Returns the last drag location of the JSplitPane. * Set the last drag location of the JSplitPane. * @return increment via keyboard methods. * Implementation of the PropertyChangeListener * that the JSplitPane UI uses. * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. // 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. * Implementation of the FocusListener that the JSplitPane UI uses. * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. // 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. * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. * Implementation of an ActionListener that the JSplitPane UI uses for * handling specific key presses. * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of BasicSplitPaneUI. * Returns the divider between the top Components. * Returns the default non continuous layout divider, which is an * instanceof Canvas that fills the background in dark gray. * Sets the divider to use when the splitPane is configured to * not continuously layout. This divider will only be used during a * dragging session. It is recommended that the passed in component * Sets the divider to use. /* Needs to remove all the components and re-add them! YECK! */ // This is all done so that the nonContinuousLayoutDivider will // be drawn on top of the other components, without this, one // of the heavyweights will draw over the divider! * Returns the divider to use when the splitPane is configured to * not continuously layout. This divider will only be used during a * Returns the splitpane this instance is currently contained * Creates the default divider. * Messaged to reset the preferred sizes. * Sets the location of the divider to location. * Returns the location of the divider, which may differ from what * the splitpane thinks the location of the divider is. * Gets the minimum location of the divider. * Gets the maximum location of the divider. * Messaged after the JSplitPane the receiver is providing the look * and feel for paints its children. * Messaged to paint the look and feel. * Returns the preferred size for the passed in component, * This is passed off to the current layoutmanager. * Returns the minimum size for the passed in component, * This is passed off to the current layoutmanager. * Returns the maximum size for the passed in component, * This is passed off to the current layoutmanager. * Returns the insets. The insets are returned from the border insets * Resets the layout manager based on orientation and messages it * with invalidateLayout to pull in appropriate Components. * Set the value to indicate if one of the splitpane sides is expanded. * The value returned indicates if one of the splitpane sides is expanded. * @return true if one of the splitpane sides is expanded, false otherwise. * Should be messaged before the dragging session starts, resets * lastDragLocation and dividerSize. * Messaged during a dragging session to move the divider to the * passed in location. If continuousLayout is true the location is * reset and the splitPane validated. * Messaged to finish the dragging session. If not continuous display * the dividers location will be reset. * As of Java 2 platform v1.3 this method is no longer used. Instead * you should set the border on the divider. * Returns the width of one side of the divider border. * @deprecated As of Java 2 platform v1.3, instead set the border on the * LayoutManager for JSplitPanes that have an orientation of /* left, right, divider. (in this exact order) */ /** Size of the splitpane the last time laid out. */ /** True if resetToPreferredSizes has been invoked. */ /** Axis, 0 for horizontal, or 1 for veritcal. */ * Does the actual layout. // If the splitpane has a zero size then no op out of here. // If we execute this function now, we're going to cause ourselves // Reset the bounds of each component // This is tricky, there is never a good time for us // to push the value to the splitpane, painted appears to // the best time to do it. What is really needed is // notification that layout has completed. // This is not always needed, but is rather tricky // to determine when... The case this is needed for // is if the user sets the divider location to some // bogus value, say 0, and the actual value is 1, the // call to setDividerLocation(1) will preserve the // old value of 0, when we really want the divider // location value before the call. This is needed for // the one touch buttons. * Adds the component at place. Place must be one of * JSplitPane.LEFT, RIGHT, TOP, BOTTOM, or null (for the * Returns the minimum size needed to contain the children. * The width is the sum of all the childrens min widths and * the height is the largest of the childrens minimum heights. * Returns the preferred size needed to contain the children. * The width is the sum of all the childrens preferred widths and * the height is the largest of the childrens preferred heights. * Removes the specified component from our knowledge. * Adds the specified component to the layout, using the specified * @param comp the component to be added * @param constraints where/how the component is added to the layout. "constraint must be a " +
* Returns the alignment along the x axis. This specifies how * the component would like to be aligned relative to other * components. The value should be a number between 0 and 1 * where 0 represents alignment along the origin, 1 is aligned * the furthest away from the origin, 0.5 is centered, etc. * Returns the alignment along the y axis. This specifies how * the component would like to be aligned relative to other * components. The value should be a number between 0 and 1 * where 0 represents alignment along the origin, 1 is aligned * the furthest away from the origin, 0.5 is centered, etc. * Does nothing. If the developer really wants to change the * size of one of the views JSplitPane.resetToPreferredSizes should * Returns the maximum layout size, which is Integer.MAX_VALUE * Marks the receiver so that the next time this instance is * laid out it'll ask for the preferred sizes. * Resets the size of the Component at the passed in location. * Sets the sizes to <code>newSizes</code>. * Returns the sizes of the components. * Returns the width of the passed in Components preferred size. * Returns the width of the passed in Components minimum size. * Returns the width of the passed in component. * Returns the available width based on the container size and * Returns the left inset, unless the Insets are null in which case * Sets the width of the component c to be size, placing its * x location at location, y to the insets.top and height * to the containersize.height less the top and bottom insets. * If the axis == 0, the width is returned, otherwise the height. * If the axis == 0, the width is returned, otherwise the height. * Returns a particular value of the inset identified by the * axis and <code>isTop</code><p> * Returns a particular value of the inset identified by the * axis and <code>isTop</code><p> * Determines the components. This should be called whenever * a new instance of this is installed into an existing * Resets the size of the first component to <code>leftSize</code>, * and the right component to the remainder of the space. * Returns an array of the minimum sizes of the components. * Returns an array of the minimum sizes of the components. * Resets the components to their preferred sizes. // Set the sizes to the preferred sizes (if fits), otherwise // set to min sizes and distribute any extra space. * Distributes <code>space</code> between the two components * (divider won't get any extra space) based on the weighting. This * attempts to honor the min size of the components. * @param keepHidden if true and one of the components is 0x0 * it gets none of the extra space // Both aren't valid, force them both to be valid // both below min, just make sure > 0 // both below min, just make sure > 0 * LayoutManager used for JSplitPanes with an orientation of // 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. // don't change the focus if the new focused component belongs // to the same splitpane and the same side // focus next side of the parent split pane