Class org.aswing.plaf.ComponentUI

Description

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.

Method Index

new ComponentUI()
create(), fillRectBackGround(), getMaximumSize(), getMinimumSize(), getPreferredSize(), installUI(), paint(), uninstallUI()

Constructor Detail

ComponentUI

public function ComponentUI()

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

Method Detail

installUI

public function installUI(c:Component):Void

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. Install keyboard UI (mnemonics, traversal, etc.) on the component.
  6. Initialize any appropriate instance data.

Parameters

cthe component where this UI delegate is being installed

See Also

uninstallUI

public function uninstallUI(c:Component):Void

Reverses configuration which was done on the specified component during installUI. This method is invoked when this ComponentUI 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 Component 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 listeners from the component.
  5. Remove any UI-installed keyboard UI from the component.
  6. Remove any UI-added MCs from this component.
  7. Nullify any allocated instance data objects to allow for GC.

Parameters

cthe 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

create

public function create(c:Component):Void

Notifies this UI delegate that it's time to create the specified component's ui MCs. This method is invoked by Component when the specified component is being created.

In general this method need not be overridden by subclasses; all look-and-feel ui creating code should reside in this method.

Parameters

cthe 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

public function paint(c:Component, g:Graphics, b:Rectangle):Void

Notifies this UI delegate that it's time to paint the specified component. This method is invoked by Component when the specified component is being painted.

In general this method need be overridden by subclasses; all look-and-feel rendering code should reside in this method. And there is a default background paint method, you should call it in your overridden paint method.

Parameters

cthe component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components.
gthe Graphics context in which to paint.
bthe bounds to paint UI in.

See Also

fillRectBackGround

static public function fillRectBackGround(c:Component, g:Graphics, b:Rectangle):Void

Utils method to paint the background of the component with the background color in the component rect.

Parameters

cthe component whose background being painted.
gthe Graphics context in which to paint.
bthe bounds to paint background in.

getPreferredSize

public function getPreferredSize(c:Component):Dimension

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

cthe 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

getMinimumSize

public function getMinimumSize(c:Component):Dimension

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

cthe 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 Dimension object or null

See Also

getMaximumSize

public function getMaximumSize(c:Component):Dimension

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

cthe 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 Dimension object or null

See Also