|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.plaf.ComponentUI
public abstract class ComponentUI
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.
Components such as 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)
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)
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(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(JComponent c)
Creates a delegate object for the specified component. |
Accessible |
getAccessibleChild(JComponent c,
int i)
Returns the specified accessible child of the component. |
int |
getAccessibleChildrenCount(JComponent c)
Counts the number of accessible children in the component. |
Dimension |
getMaximumSize(JComponent c)
Determines the maximum size of a component. |
Dimension |
getMinimumSize(JComponent c)
Determines the minimum size of a component. |
Dimension |
getPreferredSize(JComponent c)
Determines the preferred size of a component. |
void |
installUI(JComponent c)
Sets up the specified component so it conforms the the design guidelines of the implemented look and feel. |
void |
paint(Graphics g,
JComponent c)
Paints the component according to the design guidelines of the look and feel. |
void |
uninstallUI(JComponent c)
Puts the specified component into the state it had before installUI(javax.swing.JComponent) was called. |
void |
update(Graphics g,
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) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ComponentUI()
Method Detail |
---|
public void installUI(JComponent c)
ComponentUI
delegate is created.
The delegate object then receives an installUI
message.
This method should perform the following tasks:
UIResource
marker
interface, such as BorderUIResource
or ColorUIResource
.LayoutManager
.JSplitPane
might install a special
component for the divider.
c
- the component for which this delegate will provide
services.uninstallUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void uninstallUI(JComponent c)
installUI(javax.swing.JComponent)
was called.
c
- the component for which this delegate has provided
services.installUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void paint(Graphics g, JComponent c)
g
- the graphics for painting.c
- the component for which this delegate performs
services.public void update(Graphics g, JComponent c)
opaque
property is false
)
before calling paint(java.awt.Graphics, javax.swing.JComponent)
.
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)
method.
g
- the graphics for painting.c
- the component for which this delegate performs
services.paint(java.awt.Graphics, javax.swing.JComponent)
,
JComponent.paintComponent(java.awt.Graphics)
public Dimension getPreferredSize(JComponent c)
null
, which means that
c
’s layout manager should be asked to
calculate the preferred size.
c
- the component for which this delegate performs services.
null
to indicate that
c
’s layout manager should be asked
for the preferred size.public Dimension getMinimumSize(JComponent c)
getPreferredSize(javax.swing.JComponent)
, but subclasses
might want to override this.
c
- the component for which this delegate performs services.
null
to indicate that
c
’s layout manager should be asked
to calculate the minimum size.public Dimension getMaximumSize(JComponent c)
getPreferredSize(javax.swing.JComponent)
, but subclasses
might want to override this.
c
- the component for which this delegate performs services.
null
to indicate that
c
’s layout manager should be asked
to calculate the maximum size.public boolean contains(JComponent c, int x, int y)
c
- the component for which this delegate performs services.x
- the x coordinate of the point, relative to the local
coordinate system of the component. Zero would be be
component’s left edge, irrespective of the location
inside its parent.y
- the y coordinate of the point, relative to the local
coordinate system of the component. Zero would be be
component’s top edge, irrespective of the location
inside its parent.public static ComponentUI createUI(JComponent c)
createUI
method of a suitable
subclass. The implementation of ComponentUI
always throws an error.
c
- the component for which a UI delegate is requested.public int getAccessibleChildrenCount(JComponent c)
AccessibleContext
of c
.
c
- the component whose accessible children
are to be counted.public Accessible getAccessibleChild(JComponent c, int i)
AccessibleContext
of c
.
i
- the index of the accessible child, starting at zero.c
- the component whose i
-th accessible child
is requested.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |