Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javax.swing.plaf
Class ComponentUI  view ComponentUI download ComponentUI.java

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

public abstract class ComponentUI
extends java.lang.Object

The abstract base class for all delegates that provide the pluggable look and feel for Swing components. User applications should not need to access this class; it is internal to Swing and the look-and-feel implementations.

[UML diagram illustrating the architecture for pluggable
 look and feels]

Components such as javax.swing.JSlider do not directly implement operations related to the look and feel of the user interface, such as painting or layout. Instead, they use a delegate object for all such tasks. In the case of JSlider, the user interface would be provided by some concrete subclass of SliderUI.

Soon after its creation, a ComponentUI will be sent an installUI(javax.swing.JComponent) 55 message. The ComponentUI will react by setting properties such as the border or the background color of the JComponent for which it provides its services. Soon before the end of its lifecycle, the ComponentUI will receive an uninstallUI(javax.swing.JComponent) 55 message, at which time the ComponentUI is expected to undo any changes.

Note that the ui of a JComponent changes whenever the user switches between look and feels. For example, the ui property of a JSlider could change from an instance of MetalSliderUI to an instance of FooSliderUI. This switch can happen at any time, but it will always be performed from inside the Swing thread.


Constructor Summary
ComponentUI()
          Constructs a new UI delegate.
 
Method Summary
 boolean contains(javax.swing.JComponent c, int x, int y)
          Determines whether a click into the component at a specified location is considered as having hit the component.
static ComponentUI createUI(javax.swing.JComponent c)
          Creates a delegate object for the specified component.
 javax.accessibility.Accessible getAccessibleChild(javax.swing.JComponent c, int i)
          Returns the specified accessible child of the component.
 int getAccessibleChildrenCount(javax.swing.JComponent c)
          Counts the number of accessible children in the component.
 java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
          Determines the maximum size of a component.
 java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
          Determines the minimum size of a component.
 java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
          Determines the preferred size of a component.
 void installUI(javax.swing.JComponent c)
          Sets up the specified component so it conforms the the design guidelines of the implemented look and feel.
 void paint(java.awt.Graphics g, javax.swing.JComponent c)
          Paints the component according to the design guidelines of the look and feel.
 void uninstallUI(javax.swing.JComponent c)
          Puts the specified component into the state it had before installUI(javax.swing.JComponent) 55 was called.
 void update(java.awt.Graphics g, javax.swing.JComponent c)
          Fills the specified component with its background color (unless the opaque property is false) before calling paint(java.awt.Graphics, javax.swing.JComponent) 55 .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentUI

public ComponentUI()
Constructs a new UI delegate.

Method Detail

installUI

public void installUI(javax.swing.JComponent c)
Sets up the specified component so it conforms the the design guidelines of the implemented look and feel. When the look and feel changes, a ComponentUI delegate is created. The delegate object then receives an installUI message.

This method should perform the following tasks:

  • Set visual properties such as borders, fonts, colors, or icons. However, no change should be performed for those properties whose values have been directly set by the client application. To allow the distinction, LookAndFeels are expected to use values that implement the UIResource marker interface, such as BorderUIResource or ColorUIResource.
  • If necessary, install a java.awt.LayoutManager.
  • Embed custom sub-components. For instance, the UI delegate for a javax.swing.JSplitPane might install a special component for the divider.
  • Register event listeners.
  • Set up properties related to keyborad navigation, such as mnemonics or focus traversal policies.


uninstallUI

public void uninstallUI(javax.swing.JComponent c)
Puts the specified component into the state it had before installUI(javax.swing.JComponent) 55 was called.


paint

public void paint(java.awt.Graphics g,
                  javax.swing.JComponent c)
Paints the component according to the design guidelines of the look and feel. Most subclasses will want to override this method.


update

public void update(java.awt.Graphics g,
                   javax.swing.JComponent c)
Fills the specified component with its background color (unless the opaque property is false) before calling paint(java.awt.Graphics, javax.swing.JComponent) 55 .

It is unlikely that a subclass needs to override this method. The actual rendering should be performed by the paint(java.awt.Graphics, javax.swing.JComponent) 55 method.


getPreferredSize

public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
Determines the preferred size of a component. The default implementation returns null, which means that c’s layout manager should be asked to calculate the preferred size.


getMinimumSize

public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
Determines the minimum size of a component. The default implementation calls getPreferredSize(javax.swing.JComponent) 55 , but subclasses might want to override this.


getMaximumSize

public java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
Determines the maximum size of a component. The default implementation calls getPreferredSize(javax.swing.JComponent) 55 , but subclasses might want to override this.


contains

public boolean contains(javax.swing.JComponent c,
                        int x,
                        int y)
Determines whether a click into the component at a specified location is considered as having hit the component. The default implementation checks whether the point falls into the component’s bounding rectangle. Some subclasses might want to override this, for example in the case of a rounded button.


createUI

public static ComponentUI createUI(javax.swing.JComponent c)
Creates a delegate object for the specified component. Users should use the createUI method of a suitable subclass. The implementation of ComponentUI always throws an error.


getAccessibleChildrenCount

public int getAccessibleChildrenCount(javax.swing.JComponent c)
Counts the number of accessible children in the component. The default implementation delegates the inquiry to the javax.accessibility.AccessibleContext of c.


getAccessibleChild

public javax.accessibility.Accessible getAccessibleChild(javax.swing.JComponent c,
                                                         int i)
Returns the specified accessible child of the component. The default implementation delegates the inquiry to the javax.accessibility.AccessibleContext of c.