< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/ComponentUI.java

Print this page

        

*** 39,49 **** /** * The base class for all UI delegate objects in the Swing pluggable * look and feel architecture. The UI delegate object for a Swing * component is responsible for implementing the aspects of the * component that depend on the look and feel. ! * The <code>JComponent</code> class * invokes methods from this class in order to delegate operations * (painting, layout calculations, etc.) that may vary depending on the * look and feel installed. <b>Client programs should not invoke methods * on this class directly.</b> * --- 39,49 ---- /** * The base class for all UI delegate objects in the Swing pluggable * look and feel architecture. The UI delegate object for a Swing * component is responsible for implementing the aspects of the * component that depend on the look and feel. ! * The {@code JComponent} class * invokes methods from this class in order to delegate operations * (painting, layout calculations, etc.) that may vary depending on the * look and feel installed. <b>Client programs should not invoke methods * on this class directly.</b> *
*** 59,81 **** public ComponentUI() { } /** * Configures the specified component appropriately for the look and feel. ! * This method is invoked when the <code>ComponentUI</code> instance is being installed * as the UI delegate on the specified component. This method should * completely configure the component for the look and feel, * including the following: * <ol> * <li>Install default property values for color, fonts, borders, * icons, opacity, etc. on the component. Whenever possible, * property values initialized by the client program should <i>not</i> * be overridden. ! * <li>Install a <code>LayoutManager</code> on the component if necessary. * <li>Create/add any required sub-components to the component. * <li>Create/install event listeners on the component. ! * <li>Create/install a <code>PropertyChangeListener</code> on the component in order * to detect and respond to component property changes appropriately. * <li>Install keyboard UI (mnemonics, traversal, etc.) on the component. * <li>Initialize any appropriate instance data. * </ol> * @param c the component where this UI delegate is being installed --- 59,81 ---- public ComponentUI() { } /** * Configures the specified component appropriately for the look and feel. ! * This method is invoked when the {@code ComponentUI} instance is being installed * as the UI delegate on the specified component. This method should * completely configure the component for the look and feel, * including the following: * <ol> * <li>Install default property values for color, fonts, borders, * icons, opacity, etc. on the component. Whenever possible, * property values initialized by the client program should <i>not</i> * be overridden. ! * <li>Install a {@code LayoutManager} on the component if necessary. * <li>Create/add any required sub-components to the component. * <li>Create/install event listeners on the component. ! * <li>Create/install a {@code PropertyChangeListener} on the component in order * to detect and respond to component property changes appropriately. * <li>Install keyboard UI (mnemonics, traversal, etc.) on the component. * <li>Initialize any appropriate instance data. * </ol> * @param c the component where this UI delegate is being installed
*** 87,101 **** public void installUI(JComponent c) { } /** * Reverses configuration which was done on the specified component during ! * <code>installUI</code>. This method is invoked when this ! * <code>UIComponent</code> instance is being removed as the UI delegate * for the specified component. This method should undo the ! * configuration performed in <code>installUI</code>, being careful to ! * leave the <code>JComponent</code> instance in a clean state (no * extraneous listeners, look-and-feel-specific property objects, etc.). * This should include the following: * <ol> * <li>Remove any UI-set borders from the component. * <li>Remove any UI-set layout managers on the component. --- 87,101 ---- public void installUI(JComponent c) { } /** * Reverses configuration which was done on the specified component during ! * {@code installUI}. This method is invoked when this ! * {@code UIComponent} instance is being removed as the UI delegate * for the specified component. This method should undo the ! * configuration performed in {@code installUI}, being careful to ! * leave the {@code JComponent} instance in a clean state (no * extraneous listeners, look-and-feel-specific property objects, etc.). * This should include the following: * <ol> * <li>Remove any UI-set borders from the component. * <li>Remove any UI-set layout managers on the component.
*** 115,130 **** public void uninstallUI(JComponent c) { } /** * Paints the specified component appropriately for the look and feel. ! * This method is invoked from the <code>ComponentUI.update</code> method when * the specified component is being painted. Subclasses should override ! * this method and use the specified <code>Graphics</code> object to * render the content of the component. * ! * @param g the <code>Graphics</code> context in which to paint * @param c the component being painted; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components * --- 115,130 ---- public void uninstallUI(JComponent c) { } /** * Paints the specified component appropriately for the look and feel. ! * This method is invoked from the {@code ComponentUI.update} method when * the specified component is being painted. Subclasses should override ! * this method and use the specified {@code Graphics} object to * render the content of the component. * ! * @param g the {@code Graphics} context in which to paint * @param c the component being painted; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components *
*** 133,152 **** public void paint(Graphics g, JComponent c) { } /** * Notifies this UI delegate that it is time to paint the specified ! * component. This method is invoked by <code>JComponent</code> * when the specified component is being painted. * * <p>By default this method fills the specified component with * its background color if its {@code opaque} property is {@code true}, * and then immediately calls {@code paint}. In general this method need * not be overridden by subclasses; all look-and-feel rendering code should * reside in the {@code paint} method. * ! * @param g the <code>Graphics</code> context in which to paint * @param c the component being painted; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components * --- 133,152 ---- public void paint(Graphics g, JComponent c) { } /** * Notifies this UI delegate that it is time to paint the specified ! * component. This method is invoked by {@code JComponent} * when the specified component is being painted. * * <p>By default this method fills the specified component with * its background color if its {@code opaque} property is {@code true}, * and then immediately calls {@code paint}. In general this method need * not be overridden by subclasses; all look-and-feel rendering code should * reside in the {@code paint} method. * ! * @param g the {@code Graphics} context in which to paint * @param c the component being painted; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components *
*** 161,175 **** paint(g, c); } /** * Returns the specified component's preferred size appropriate for ! * the look and feel. If <code>null</code> is returned, the preferred * size will be calculated by the component's layout manager instead * (this is the preferred approach for any component with a specific * layout manager installed). The default implementation of this ! * method returns <code>null</code>. * * @param c the component whose preferred size is being queried; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components --- 161,175 ---- paint(g, c); } /** * Returns the specified component's preferred size appropriate for ! * the look and feel. If {@code null} is returned, the preferred * size will be calculated by the component's layout manager instead * (this is the preferred approach for any component with a specific * layout manager installed). The default implementation of this ! * method returns {@code null}. * * @param c the component whose preferred size is being queried; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components
*** 182,203 **** return null; } /** * Returns the specified component's minimum size appropriate for ! * the look and feel. If <code>null</code> is returned, the minimum * size will be calculated by the component's layout manager instead * (this is the preferred approach for any component with a specific * layout manager installed). The default implementation of this ! * method invokes <code>getPreferredSize</code> and returns that value. * * @param c the component whose minimum size is being queried; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components * ! * @return a <code>Dimension</code> object or <code>null</code> * * @see javax.swing.JComponent#getMinimumSize * @see java.awt.LayoutManager#minimumLayoutSize * @see #getPreferredSize */ --- 182,203 ---- return null; } /** * Returns the specified component's minimum size appropriate for ! * the look and feel. If {@code null} is returned, the minimum * size will be calculated by the component's layout manager instead * (this is the preferred approach for any component with a specific * layout manager installed). The default implementation of this ! * method invokes {@code getPreferredSize} and returns that value. * * @param c the component whose minimum size is being queried; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components * ! * @return a {@code Dimension} object or {@code null} * * @see javax.swing.JComponent#getMinimumSize * @see java.awt.LayoutManager#minimumLayoutSize * @see #getPreferredSize */
*** 205,239 **** return getPreferredSize(c); } /** * Returns the specified component's maximum size appropriate for ! * the look and feel. If <code>null</code> is returned, the maximum * size will be calculated by the component's layout manager instead * (this is the preferred approach for any component with a specific * layout manager installed). The default implementation of this ! * method invokes <code>getPreferredSize</code> and returns that value. * * @param c the component whose maximum size is being queried; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components ! * @return a <code>Dimension</code> object or <code>null</code> * * @see javax.swing.JComponent#getMaximumSize * @see java.awt.LayoutManager2#maximumLayoutSize */ public Dimension getMaximumSize(JComponent c) { return getPreferredSize(c); } /** ! * Returns <code>true</code> if the specified <i>x,y</i> location is * contained within the look and feel's defined shape of the specified ! * component. <code>x</code> and <code>y</code> are defined to be relative * to the coordinate system of the specified component. Although ! * a component's <code>bounds</code> is constrained to a rectangle, * this method provides the means for defining a non-rectangular * shape within those bounds for the purpose of hit detection. * * @param c the component where the <i>x,y</i> location is being queried; * this argument is often ignored, --- 205,239 ---- return getPreferredSize(c); } /** * Returns the specified component's maximum size appropriate for ! * the look and feel. If {@code null} is returned, the maximum * size will be calculated by the component's layout manager instead * (this is the preferred approach for any component with a specific * layout manager installed). The default implementation of this ! * method invokes {@code getPreferredSize} and returns that value. * * @param c the component whose maximum size is being queried; * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components ! * @return a {@code Dimension} object or {@code null} * * @see javax.swing.JComponent#getMaximumSize * @see java.awt.LayoutManager2#maximumLayoutSize */ public Dimension getMaximumSize(JComponent c) { return getPreferredSize(c); } /** ! * Returns {@code true} if the specified <i>x,y</i> location is * contained within the look and feel's defined shape of the specified ! * component. {@code x} and {@code y} are defined to be relative * to the coordinate system of the specified component. Although ! * a component's {@code bounds} is constrained to a rectangle, * this method provides the means for defining a non-rectangular * shape within those bounds for the purpose of hit detection. * * @param c the component where the <i>x,y</i> location is being queried; * this argument is often ignored,
*** 251,261 **** return c.inside(x, y); } /** * Returns an instance of the UI delegate for the specified component. ! * Each subclass must provide its own static <code>createUI</code> * method that returns an instance of that UI delegate subclass. * If the UI delegate subclass is stateless, it may return an instance * that is shared by multiple components. If the UI delegate is * stateful, then it should return a new instance per component. * The default implementation of this method throws an error, as it --- 251,261 ---- return c.inside(x, y); } /** * Returns an instance of the UI delegate for the specified component. ! * Each subclass must provide its own static {@code createUI} * method that returns an instance of that UI delegate subclass. * If the UI delegate subclass is stateless, it may return an instance * that is shared by multiple components. If the UI delegate is * stateful, then it should return a new instance per component. * The default implementation of this method throws an error, as it
*** 269,291 **** } /** * Returns the baseline. The baseline is measured from the top of * the component. This method is primarily meant for ! * <code>LayoutManager</code>s to align components along their * baseline. A return value less than 0 indicates this component * does not have a reasonable baseline and that ! * <code>LayoutManager</code>s should not align this component on * its baseline. * <p> * This method returns -1. Subclasses that have a meaningful baseline * should override appropriately. * ! * @param c <code>JComponent</code> baseline is being requested for * @param width the width to get the baseline for * @param height the height to get the baseline for ! * @throws NullPointerException if <code>c</code> is <code>null</code> * @throws IllegalArgumentException if width or height is &lt; 0 * @return baseline or a value &lt; 0 indicating there is no reasonable * baseline * @see javax.swing.JComponent#getBaseline(int,int) * @since 1.6 --- 269,291 ---- } /** * Returns the baseline. The baseline is measured from the top of * the component. This method is primarily meant for ! * {@code LayoutManager}s to align components along their * baseline. A return value less than 0 indicates this component * does not have a reasonable baseline and that ! * {@code LayoutManager}s should not align this component on * its baseline. * <p> * This method returns -1. Subclasses that have a meaningful baseline * should override appropriately. * ! * @param c {@code JComponent} baseline is being requested for * @param width the width to get the baseline for * @param height the height to get the baseline for ! * @throws NullPointerException if {@code c} is {@code null} * @throws IllegalArgumentException if width or height is &lt; 0 * @return baseline or a value &lt; 0 indicating there is no reasonable * baseline * @see javax.swing.JComponent#getBaseline(int,int) * @since 1.6
*** 304,320 **** /** * Returns an enum indicating how the baseline of the component * changes as the size changes. This method is primarily meant for * layout managers and GUI builders. * <p> ! * This method returns <code>BaselineResizeBehavior.OTHER</code>. * Subclasses that support a baseline should override appropriately. * ! * @param c <code>JComponent</code> to return baseline resize behavior for * @return an enum indicating how the baseline changes as the component * size changes ! * @throws NullPointerException if <code>c</code> is <code>null</code> * @see javax.swing.JComponent#getBaseline(int, int) * @since 1.6 */ public Component.BaselineResizeBehavior getBaselineResizeBehavior( JComponent c) { --- 304,320 ---- /** * Returns an enum indicating how the baseline of the component * changes as the size changes. This method is primarily meant for * layout managers and GUI builders. * <p> ! * This method returns {@code BaselineResizeBehavior.OTHER}. * Subclasses that support a baseline should override appropriately. * ! * @param c {@code JComponent} to return baseline resize behavior for * @return an enum indicating how the baseline changes as the component * size changes ! * @throws NullPointerException if {@code c} is {@code null} * @see javax.swing.JComponent#getBaseline(int, int) * @since 1.6 */ public Component.BaselineResizeBehavior getBaselineResizeBehavior( JComponent c) {
*** 324,342 **** return Component.BaselineResizeBehavior.OTHER; } /** * Returns the number of accessible children in the object. If all ! * of the children of this object implement <code>Accessible</code>, * this * method should return the number of children of this object. * UIs might wish to override this if they present areas on the * screen that can be viewed as components, but actual components * are not used for presenting those areas. * * Note: As of v1.3, it is recommended that developers call ! * <code>Component.AccessibleAWTComponent.getAccessibleChildrenCount()</code> instead * of this method. * * @param c {@code JComponent} for which to get count of accessible children * @return the number of accessible children in the object * @see #getAccessibleChild --- 324,342 ---- return Component.BaselineResizeBehavior.OTHER; } /** * Returns the number of accessible children in the object. If all ! * of the children of this object implement {@code Accessible}, * this * method should return the number of children of this object. * UIs might wish to override this if they present areas on the * screen that can be viewed as components, but actual components * are not used for presenting those areas. * * Note: As of v1.3, it is recommended that developers call ! * {@code Component.AccessibleAWTComponent.getAccessibleChildrenCount()} instead * of this method. * * @param c {@code JComponent} for which to get count of accessible children * @return the number of accessible children in the object * @see #getAccessibleChild
*** 344,367 **** public int getAccessibleChildrenCount(JComponent c) { return SwingUtilities.getAccessibleChildrenCount(c); } /** ! * Returns the <code>i</code>th <code>Accessible</code> child of the object. * UIs might need to override this if they present areas on the * screen that can be viewed as components, but actual components * are not used for presenting those areas. * * <p> * * Note: As of v1.3, it is recommended that developers call ! * <code>Component.AccessibleAWTComponent.getAccessibleChild()</code> instead of * this method. * * @param c a {@code JComponent} for which to get a child object * @param i zero-based index of child ! * @return the <code>i</code>th <code>Accessible</code> child of the object * @see #getAccessibleChildrenCount */ public Accessible getAccessibleChild(JComponent c, int i) { return SwingUtilities.getAccessibleChild(c, i); } --- 344,367 ---- public int getAccessibleChildrenCount(JComponent c) { return SwingUtilities.getAccessibleChildrenCount(c); } /** ! * Returns the {@code i}th {@code Accessible} child of the object. * UIs might need to override this if they present areas on the * screen that can be viewed as components, but actual components * are not used for presenting those areas. * * <p> * * Note: As of v1.3, it is recommended that developers call ! * {@code Component.AccessibleAWTComponent.getAccessibleChild()} instead of * this method. * * @param c a {@code JComponent} for which to get a child object * @param i zero-based index of child ! * @return the {@code i}th {@code Accessible} child of the object * @see #getAccessibleChildrenCount */ public Accessible getAccessibleChild(JComponent c, int i) { return SwingUtilities.getAccessibleChild(c, i); }
< prev index next >