javax.swing.plaf
Class ComponentUI

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.plaf.ComponentUI
Direct Known Subclasses:
ButtonUI sample code for javax.swing.plaf.ButtonUI definition code for javax.swing.plaf.ButtonUI , ColorChooserUI sample code for javax.swing.plaf.ColorChooserUI definition code for javax.swing.plaf.ColorChooserUI , ComboBoxUI sample code for javax.swing.plaf.ComboBoxUI definition code for javax.swing.plaf.ComboBoxUI , DesktopIconUI sample code for javax.swing.plaf.DesktopIconUI definition code for javax.swing.plaf.DesktopIconUI , DesktopPaneUI sample code for javax.swing.plaf.DesktopPaneUI definition code for javax.swing.plaf.DesktopPaneUI , FileChooserUI sample code for javax.swing.plaf.FileChooserUI definition code for javax.swing.plaf.FileChooserUI , InternalFrameUI sample code for javax.swing.plaf.InternalFrameUI definition code for javax.swing.plaf.InternalFrameUI , LabelUI sample code for javax.swing.plaf.LabelUI definition code for javax.swing.plaf.LabelUI , ListUI sample code for javax.swing.plaf.ListUI definition code for javax.swing.plaf.ListUI , MenuBarUI sample code for javax.swing.plaf.MenuBarUI definition code for javax.swing.plaf.MenuBarUI , OptionPaneUI sample code for javax.swing.plaf.OptionPaneUI definition code for javax.swing.plaf.OptionPaneUI , PanelUI sample code for javax.swing.plaf.PanelUI definition code for javax.swing.plaf.PanelUI , PopupMenuUI sample code for javax.swing.plaf.PopupMenuUI definition code for javax.swing.plaf.PopupMenuUI , ProgressBarUI sample code for javax.swing.plaf.ProgressBarUI definition code for javax.swing.plaf.ProgressBarUI , RootPaneUI sample code for javax.swing.plaf.RootPaneUI definition code for javax.swing.plaf.RootPaneUI , ScrollBarUI sample code for javax.swing.plaf.ScrollBarUI definition code for javax.swing.plaf.ScrollBarUI , ScrollPaneUI sample code for javax.swing.plaf.ScrollPaneUI definition code for javax.swing.plaf.ScrollPaneUI , SeparatorUI sample code for javax.swing.plaf.SeparatorUI definition code for javax.swing.plaf.SeparatorUI , SliderUI sample code for javax.swing.plaf.SliderUI definition code for javax.swing.plaf.SliderUI , SpinnerUI sample code for javax.swing.plaf.SpinnerUI definition code for javax.swing.plaf.SpinnerUI , SplitPaneUI sample code for javax.swing.plaf.SplitPaneUI definition code for javax.swing.plaf.SplitPaneUI , TabbedPaneUI sample code for javax.swing.plaf.TabbedPaneUI definition code for javax.swing.plaf.TabbedPaneUI , TableHeaderUI sample code for javax.swing.plaf.TableHeaderUI definition code for javax.swing.plaf.TableHeaderUI , TableUI sample code for javax.swing.plaf.TableUI definition code for javax.swing.plaf.TableUI , TextUI sample code for javax.swing.plaf.TextUI definition code for javax.swing.plaf.TextUI , ToolBarUI sample code for javax.swing.plaf.ToolBarUI definition code for javax.swing.plaf.ToolBarUI , ToolTipUI sample code for javax.swing.plaf.ToolTipUI definition code for javax.swing.plaf.ToolTipUI , TreeUI sample code for javax.swing.plaf.TreeUI definition code for javax.swing.plaf.TreeUI , ViewportUI sample code for javax.swing.plaf.ViewportUI definition code for javax.swing.plaf.ViewportUI

public abstract class ComponentUI
extends Object sample code for java.lang.Object definition code for java.lang.Object

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 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. Client programs should not invoke methods on this class directly.

See Also:
JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent , UIManager sample code for javax.swing.UIManager definition code for javax.swing.UIManager

Constructor Summary
ComponentUI sample code for javax.swing.plaf.ComponentUI.ComponentUI() definition code for javax.swing.plaf.ComponentUI.ComponentUI() ()
          Sole constructor.
 
Method Summary
 boolean contains sample code for javax.swing.plaf.ComponentUI.contains(javax.swing.JComponent, int, int) definition code for javax.swing.plaf.ComponentUI.contains(javax.swing.JComponent, int, int) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c, int x, int y)
          Returns true if the specified x,y location is contained within the look and feel's defined shape of the specified component.
static ComponentUI sample code for javax.swing.plaf.ComponentUI definition code for javax.swing.plaf.ComponentUI createUI sample code for javax.swing.plaf.ComponentUI.createUI(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.createUI(javax.swing.JComponent) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
          Returns an instance of the UI delegate for the specified component.
 Accessible sample code for javax.accessibility.Accessible definition code for javax.accessibility.Accessible getAccessibleChild sample code for javax.swing.plaf.ComponentUI.getAccessibleChild(javax.swing.JComponent, int) definition code for javax.swing.plaf.ComponentUI.getAccessibleChild(javax.swing.JComponent, int) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c, int i)
          Returns the ith Accessible child of the object.
 int getAccessibleChildrenCount sample code for javax.swing.plaf.ComponentUI.getAccessibleChildrenCount(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getAccessibleChildrenCount(javax.swing.JComponent) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
          Returns the number of accessible children in the object.
 Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension getMaximumSize sample code for javax.swing.plaf.ComponentUI.getMaximumSize(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getMaximumSize(javax.swing.JComponent) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
          Returns the specified component's maximum size appropriate for the look and feel.
 Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension getMinimumSize sample code for javax.swing.plaf.ComponentUI.getMinimumSize(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getMinimumSize(javax.swing.JComponent) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
          Returns the specified component's minimum size appropriate for the look and feel.
 Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension getPreferredSize sample code for javax.swing.plaf.ComponentUI.getPreferredSize(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getPreferredSize(javax.swing.JComponent) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
          Returns the specified component's preferred size appropriate for the look and feel.
 void installUI sample code for javax.swing.plaf.ComponentUI.installUI(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.installUI(javax.swing.JComponent) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
          Configures the specified component appropriate for the look and feel.
 void paint sample code for javax.swing.plaf.ComponentUI.paint(java.awt.Graphics, javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.paint(java.awt.Graphics, javax.swing.JComponent) (Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  g, JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
          Paints the specified component appropriate for the look and feel.
 void uninstallUI sample code for javax.swing.plaf.ComponentUI.uninstallUI(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.uninstallUI(javax.swing.JComponent) (JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
          Reverses configuration which was done on the specified component during installUI.
 void update sample code for javax.swing.plaf.ComponentUI.update(java.awt.Graphics, javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.update(java.awt.Graphics, javax.swing.JComponent) (Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  g, JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
          Notifies this UI delegate that it's time to paint the specified component.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

ComponentUI sample code for javax.swing.plaf.ComponentUI() definition code for javax.swing.plaf.ComponentUI()

public ComponentUI()
Sole constructor. (For invocation by subclass constructors, typically implicit.)

Method Detail

installUI sample code for javax.swing.plaf.ComponentUI.installUI(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.installUI(javax.swing.JComponent)

public void installUI(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
Configures the specified component appropriate for the look and feel. This method is invoked when the 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:
  1. Install any default property values for color, fonts, borders, icons, opacity, etc. on the component. Whenever possible, property values initialized by the client program should not be overridden.
  2. Install a LayoutManager on the component if necessary.
  3. Create/add any required sub-components to the component.
  4. Create/install event listeners on the component.
  5. Create/install a PropertyChangeListener on the component in order to detect and respond to component property changes appropriately.
  6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
  7. Initialize any appropriate instance data.

Parameters:
c - the component where this UI delegate is being installed
See Also:
uninstallUI(javax.swing.JComponent) sample code for javax.swing.plaf.ComponentUI.uninstallUI(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.uninstallUI(javax.swing.JComponent) , JComponent.setUI(javax.swing.plaf.ComponentUI) sample code for javax.swing.JComponent.setUI(javax.swing.plaf.ComponentUI) definition code for javax.swing.JComponent.setUI(javax.swing.plaf.ComponentUI) , JComponent.updateUI() sample code for javax.swing.JComponent.updateUI() definition code for javax.swing.JComponent.updateUI()

uninstallUI sample code for javax.swing.plaf.ComponentUI.uninstallUI(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.uninstallUI(javax.swing.JComponent)

public void uninstallUI(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
Reverses configuration which was done on the specified component during installUI. This method is invoked when this UIComponent instance is being removed as the UI delegate for the specified component. This method should undo the configuration performed in installUI, being careful to leave the JComponent instance in a clean state (no extraneous listeners, look-and-feel-specific property objects, etc.). This should include the following:
  1. Remove any UI-set borders from the component.
  2. Remove any UI-set layout managers on the component.
  3. Remove any UI-added sub-components from the component.
  4. Remove any UI-added event/property listeners from the component.
  5. Remove any UI-installed keyboard UI from the component.
  6. Nullify any allocated instance data objects to allow for GC.

Parameters:
c - the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
See Also:
installUI(javax.swing.JComponent) sample code for javax.swing.plaf.ComponentUI.installUI(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.installUI(javax.swing.JComponent) , JComponent.updateUI() sample code for javax.swing.JComponent.updateUI() definition code for javax.swing.JComponent.updateUI()

paint sample code for javax.swing.plaf.ComponentUI.paint(java.awt.Graphics, javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.paint(java.awt.Graphics, javax.swing.JComponent)

public void paint(Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  g,
                  JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
Paints the specified component appropriate for the look and feel. This method is invoked from the ComponentUI.update method when the specified component is being painted. Subclasses should override this method and use the specified Graphics object to render the content of the component.

Parameters:
g - the Graphics context in which to paint
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
See Also:
update(java.awt.Graphics, javax.swing.JComponent) sample code for javax.swing.plaf.ComponentUI.update(java.awt.Graphics, javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)

update sample code for javax.swing.plaf.ComponentUI.update(java.awt.Graphics, javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)

public void update(Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  g,
                   JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
Notifies this UI delegate that it's time to paint the specified component. This method is invoked by JComponent when the specified component is being painted. By default this method will fill the specified component with its background color (if its opaque property is true) and then immediately call paint. In general this method need not be overridden by subclasses; all look-and-feel rendering code should reside in the paint method.

Parameters:
g - the Graphics context in which to paint
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
See Also:
paint(java.awt.Graphics, javax.swing.JComponent) sample code for javax.swing.plaf.ComponentUI.paint(java.awt.Graphics, javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.paint(java.awt.Graphics, javax.swing.JComponent) , JComponent.paintComponent(java.awt.Graphics) sample code for javax.swing.JComponent.paintComponent(java.awt.Graphics) definition code for javax.swing.JComponent.paintComponent(java.awt.Graphics)

getPreferredSize sample code for javax.swing.plaf.ComponentUI.getPreferredSize(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getPreferredSize(javax.swing.JComponent)

public Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension  getPreferredSize(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
Returns the specified component's preferred size appropriate for the look and feel. If 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 null.

Parameters:
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
See Also:
JComponent.getPreferredSize() sample code for javax.swing.JComponent.getPreferredSize() definition code for javax.swing.JComponent.getPreferredSize() , LayoutManager.preferredLayoutSize(java.awt.Container) sample code for java.awt.LayoutManager.preferredLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager.preferredLayoutSize(java.awt.Container)

getMinimumSize sample code for javax.swing.plaf.ComponentUI.getMinimumSize(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getMinimumSize(javax.swing.JComponent)

public Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension  getMinimumSize(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
Returns the specified component's minimum size appropriate for the look and feel. If 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 getPreferredSize and returns that value.

Parameters:
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
Returns:
a Dimension object or null
See Also:
JComponent.getMinimumSize() sample code for javax.swing.JComponent.getMinimumSize() definition code for javax.swing.JComponent.getMinimumSize() , LayoutManager.minimumLayoutSize(java.awt.Container) sample code for java.awt.LayoutManager.minimumLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager.minimumLayoutSize(java.awt.Container) , getPreferredSize(javax.swing.JComponent) sample code for javax.swing.plaf.ComponentUI.getPreferredSize(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getPreferredSize(javax.swing.JComponent)

getMaximumSize sample code for javax.swing.plaf.ComponentUI.getMaximumSize(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getMaximumSize(javax.swing.JComponent)

public Dimension sample code for java.awt.Dimension definition code for java.awt.Dimension  getMaximumSize(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
Returns the specified component's maximum size appropriate for the look and feel. If 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 getPreferredSize and returns that value.

Parameters:
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
Returns:
a Dimension object or null
See Also:
JComponent.getMaximumSize() sample code for javax.swing.JComponent.getMaximumSize() definition code for javax.swing.JComponent.getMaximumSize() , LayoutManager2.maximumLayoutSize(java.awt.Container) sample code for java.awt.LayoutManager2.maximumLayoutSize(java.awt.Container) definition code for java.awt.LayoutManager2.maximumLayoutSize(java.awt.Container)

contains sample code for javax.swing.plaf.ComponentUI.contains(javax.swing.JComponent, int, int) definition code for javax.swing.plaf.ComponentUI.contains(javax.swing.JComponent, int, int)

public boolean contains(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c,
                        int x,
                        int y)
Returns true if the specified x,y location is contained within the look and feel's defined shape of the specified component. x and y are defined to be relative to the coordinate system of the specified component. Although a component's 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.

Parameters:
c - the component where the x,y location is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
x - the x coordinate of the point
y - the y coordinate of the point
See Also:
JComponent.contains(int, int) sample code for javax.swing.JComponent.contains(int, int) definition code for javax.swing.JComponent.contains(int, int) , Component.contains(int, int) sample code for java.awt.Component.contains(int, int) definition code for java.awt.Component.contains(int, int)

createUI sample code for javax.swing.plaf.ComponentUI.createUI(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.createUI(javax.swing.JComponent)

public static ComponentUI sample code for javax.swing.plaf.ComponentUI definition code for javax.swing.plaf.ComponentUI  createUI(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
Returns an instance of the UI delegate for the specified component. Each subclass must provide its own static 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 should never be invoked.


getAccessibleChildrenCount sample code for javax.swing.plaf.ComponentUI.getAccessibleChildrenCount(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getAccessibleChildrenCount(javax.swing.JComponent)

public int getAccessibleChildrenCount(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c)
Returns the number of accessible children in the object. If all of the children of this object implement 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 Component.AccessibleAWTComponent.getAccessibleChildrenCount() instead of this method.

Returns:
the number of accessible children in the object
See Also:
getAccessibleChild(javax.swing.JComponent, int) sample code for javax.swing.plaf.ComponentUI.getAccessibleChild(javax.swing.JComponent, int) definition code for javax.swing.plaf.ComponentUI.getAccessibleChild(javax.swing.JComponent, int)

getAccessibleChild sample code for javax.swing.plaf.ComponentUI.getAccessibleChild(javax.swing.JComponent, int) definition code for javax.swing.plaf.ComponentUI.getAccessibleChild(javax.swing.JComponent, int)

public Accessible sample code for javax.accessibility.Accessible definition code for javax.accessibility.Accessible  getAccessibleChild(JComponent sample code for javax.swing.JComponent definition code for javax.swing.JComponent  c,
                                     int i)
Returns the ith 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.

Note: As of v1.3, it is recommended that developers call Component.AccessibleAWTComponent.getAccessibleChild() instead of this method.

Parameters:
i - zero-based index of child
Returns:
the ith Accessible child of the object
See Also:
getAccessibleChildrenCount(javax.swing.JComponent) sample code for javax.swing.plaf.ComponentUI.getAccessibleChildrenCount(javax.swing.JComponent) definition code for javax.swing.plaf.ComponentUI.getAccessibleChildrenCount(javax.swing.JComponent)