PropertyChangeListener
, EventListener
MetalLabelUI
, SynthLabelUI
public class BasicLabelUI extends LabelUI implements PropertyChangeListener
Modifier and Type | Field | Description |
---|---|---|
protected static BasicLabelUI |
labelUI |
The default BasicLabelUI instance. |
Constructor | Description |
---|---|
BasicLabelUI() |
Constructs a BasicLabelUI . |
Modifier and Type | Method | Description |
---|---|---|
static ComponentUI |
createUI |
Returns an instance of BasicLabelUI . |
int |
getBaseline |
Returns the baseline. |
Component.BaselineResizeBehavior |
getBaselineResizeBehavior |
Returns an enum indicating how the baseline of the component changes as the size changes. |
Dimension |
getMaximumSize |
Returns the specified component's maximum size appropriate for the look and feel. |
Dimension |
getMinimumSize |
Returns the specified component's minimum size appropriate for the look and feel. |
protected void |
installComponents |
Registers components. |
protected void |
installDefaults |
Installs default properties. |
protected void |
installKeyboardActions |
Registers keyboard actions. |
protected void |
installListeners |
Registers listeners. |
protected String |
layoutCL |
Forwards the call to SwingUtilities.layoutCompoundLabel(). |
void |
paint |
Paints the label text with the foreground color, if the label is opaque then paints the entire background with the background color. |
protected void |
paintDisabledText |
Paint clippedText at textX, textY with background.lighter() and then shifted down and to the right by one pixel with background.darker(). |
protected void |
paintEnabledText |
Paint clippedText at textX, textY with the labels foreground color. |
void |
propertyChange |
This method gets called when a bound property is changed. |
protected void |
uninstallComponents |
Unregisters components. |
protected void |
uninstallDefaults |
Uninstalls default properties. |
protected void |
uninstallKeyboardActions |
Unregisters keyboard actions. |
protected void |
uninstallListeners |
Unregisters listeners. |
contains, getAccessibleChild, getAccessibleChildrenCount, getPreferredSize, installUI, uninstallUI, update
protected static BasicLabelUI labelUI
BasicLabelUI
instance. This field might not be used. To change the default instance use a subclass which overrides the createUI
method, and place that class name in defaults table under the key "LabelUI".public BasicLabelUI()
BasicLabelUI
.protected String layoutCL(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR)
label
- an instance of JLabel
fontMetrics
- a font metricstext
- a texticon
- an iconviewR
- a bounding rectangle to lay out labeliconR
- a bounding rectangle to lay out icontextR
- a bounding rectangle to lay out textprotected void paintEnabledText(JLabel l, Graphics g, String s, int textX, int textY)
l
- an instance of JLabel
g
- an instance of Graphics
s
- a texttextX
- an X coordinatetextY
- an Y coordinateprotected void paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY)
l
- an instance of JLabel
g
- an instance of Graphics
s
- a texttextX
- an X coordinatetextY
- an Y coordinatepublic void paint(Graphics g, JComponent c)
paintEnabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int)
or paintDisabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int)
. The locations of the label parts are computed by layoutCL(javax.swing.JLabel, java.awt.FontMetrics, java.lang.String, javax.swing.Icon, java.awt.Rectangle, java.awt.Rectangle, java.awt.Rectangle)
.paint
in class ComponentUI
g
- the Graphics
context in which to paintc
- the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentspublic Dimension getMinimumSize(JComponent c)
ComponentUI
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.getMinimumSize
in class ComponentUI
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 componentspublic Dimension getMaximumSize(JComponent c)
ComponentUI
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.getMaximumSize
in class ComponentUI
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 componentspublic int getBaseline(JComponent c, int width, int height)
getBaseline
in class ComponentUI
c
- JComponent
baseline is being requested forwidth
- the width to get the baseline forheight
- the height to get the baseline forNullPointerException
- if c
is null
IllegalArgumentException
- if width or height is < 0public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior
in class ComponentUI
c
- JComponent
to return baseline resize behavior forNullPointerException
- if c
is null
protected void installDefaults(JLabel c)
c
- an instance of JLabel
protected void installListeners(JLabel c)
c
- an instance of JLabel
protected void installComponents(JLabel c)
c
- an instance of JLabel
protected void installKeyboardActions(JLabel l)
l
- an instance of JLabel
protected void uninstallDefaults(JLabel c)
c
- an instance of JLabel
protected void uninstallListeners(JLabel c)
c
- an instance of JLabel
protected void uninstallComponents(JLabel c)
c
- an instance of JLabel
protected void uninstallKeyboardActions(JLabel c)
c
- an instance of JLabel
public static ComponentUI createUI(JComponent c)
BasicLabelUI
.c
- a componentBasicLabelUI
public void propertyChange(PropertyChangeEvent e)
PropertyChangeListener
propertyChange
in interface PropertyChangeListener
e
- A PropertyChangeEvent object describing the event source and the property that has changed.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/plaf/basic/BasicLabelUI.html