public class BasicLabelUI extends LabelUIimplements PropertyChangeListener
| Modifier and Type | Field and Description |
|---|---|
protected static BasicLabelUI |
labelUI
The default
BasicLabelUI instance.
|
| Constructor and Description |
|---|
BasicLabelUI()
|
| Modifier and Type | Method and Description |
|---|---|
static ComponentUI |
createUI(JComponent
|
int |
getBaseline(JComponent
Returns the baseline.
|
Component |
getBaselineResizeBehavior(JComponent
Returns an enum indicating how the baseline of the component changes as the size changes.
|
Dimension |
getMaximumSize(JComponent
Returns the specified component's maximum size appropriate for the look and feel.
|
Dimension |
getMinimumSize(JComponent
Returns the specified component's minimum size appropriate for the look and feel.
|
Dimension |
getPreferredSize(JComponent
Returns the specified component's preferred size appropriate for the look and feel.
|
protected void |
installComponents(JLabel
|
protected void |
installDefaults(JLabel
|
protected void |
installKeyboardActions(JLabel
|
protected void |
installListeners(JLabel
|
void |
installUI(JComponent
Configures the specified component appropriately for the look and feel.
|
protected String |
layoutCL(JLabel
Forwards the call to SwingUtilities.layoutCompoundLabel().
|
void |
paint(Graphics
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(JLabel
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(JLabel
Paint clippedText at textX, textY with the labels foreground color.
|
void |
propertyChange(PropertyChangeEvent
This method gets called when a bound property is changed.
|
protected void |
uninstallComponents(JLabel
|
protected void |
uninstallDefaults(JLabel
|
protected void |
uninstallKeyboardActions(JLabel
|
protected void |
uninstallListeners(JLabel
|
void |
uninstallUI(JComponent
Reverses configuration which was done on the specified component during
installUI.
|
contains, getAccessibleChild, getAccessibleChildrenCount, updateprotected static BasicLabelUIlabelUI
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".
protected StringlayoutCL(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR)
protected void paintEnabledText(JLabell, Graphics g, String s, int textX, int textY)
protected void paintDisabledText(JLabell, Graphics g, String s, int textX, int textY)
public void paint(Graphicsg, 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 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
paintEnabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int),
paintDisabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int),
layoutCL(javax.swing.JLabel, java.awt.FontMetrics, java.lang.String, javax.swing.Icon, java.awt.Rectangle, java.awt.Rectangle, java.awt.Rectangle)
public DimensiongetPreferredSize(JComponent c)
ComponentUI
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.
getPreferredSize in class
ComponentUI
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
JComponent.getPreferredSize() ,
LayoutManager.preferredLayoutSize(java.awt.Container)
public DimensiongetMinimumSize(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 components
JComponent.getMinimumSize() ,
LayoutManager.minimumLayoutSize(java.awt.Container) ,
ComponentUI.getPreferredSize(javax.swing.JComponent)
public DimensiongetMaximumSize(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 components
JComponent.getMaximumSize() ,
LayoutManager2.maximumLayoutSize(java.awt.Container)
public int getBaseline(JComponentc, int width, int height)
getBaseline in class
ComponentUI
c -
JComponent baseline is being requested for
width - the width to get the baseline for
height - the height to get the baseline for
NullPointerException - if
c is
null
IllegalArgumentException - if width or height is < 0
JComponent.getBaseline(int, int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior in class
ComponentUI
c -
JComponent to return baseline resize behavior for
NullPointerException - if
c is
null
JComponent.getBaseline(int, int)
public void installUI(JComponentc)
ComponentUI
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:
LayoutManager on the component if necessary. PropertyChangeListener on the component in order to detect and respond to component property changes appropriately. installUI in class
ComponentUI
c - the component where this UI delegate is being installed
ComponentUI.uninstallUI(javax.swing.JComponent) ,
JComponent.setUI(javax.swing.plaf.ComponentUI) ,
JComponent.updateUI()
public void uninstallUI(JComponentc)
ComponentUI
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:
uninstallUI in class
ComponentUI
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
ComponentUI.installUI(javax.swing.JComponent) ,
JComponent.updateUI()
protected void installDefaults(JLabelc)
protected void installListeners(JLabelc)
protected void installComponents(JLabelc)
protected void installKeyboardActions(JLabell)
protected void uninstallDefaults(JLabelc)
protected void uninstallListeners(JLabelc)
protected void uninstallComponents(JLabelc)
protected void uninstallKeyboardActions(JLabelc)
public static ComponentUIcreateUI(JComponent c)
public void propertyChange(PropertyChangeEvente)
PropertyChangeListener
propertyChange in interface
PropertyChangeListener
e - A PropertyChangeEvent object describing the event source and the property that has changed.