Class BasicLabelUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.LabelUI
javax.swing.plaf.basic.BasicLabelUI
- All Implemented Interfaces:
- PropertyChangeListener,- EventListener
- Direct Known Subclasses:
- MetalLabelUI,- SynthLabelUI
A Windows L&F implementation of LabelUI.  This implementation
 is completely static, i.e. there's only one UIView implementation
 that's shared by all JLabel objects.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static BasicLabelUIThe defaultBasicLabelUIinstance.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic ComponentUIReturns an instance ofBasicLabelUI.intgetBaseline(JComponent c, int width, int height) Returns the baseline.Returns an enum indicating how the baseline of the component changes as the size changes.Returns the specified component's maximum size appropriate for the look and feel.Returns the specified component's minimum size appropriate for the look and feel.protected voidRegisters components.protected voidInstalls default properties.protected voidRegisters keyboard actions.protected voidRegisters listeners.protected StringlayoutCL(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR) Forwards the call to SwingUtilities.layoutCompoundLabel().voidpaint(Graphics g, JComponent c) Paints the label text with the foreground color, if the label is opaque then paints the entire background with the background color.protected voidpaintDisabledText(JLabel l, Graphics g, String s, int textX, int textY) Paint clippedText at textX, textY with background.lighter() and then shifted down and to the right by one pixel with background.darker().protected voidpaintEnabledText(JLabel l, Graphics g, String s, int textX, int textY) Paint clippedText at textX, textY with the labels foreground color.voidThis method gets called when a bound property is changed.protected voidUnregisters components.protected voidUninstalls default properties.protected voidUnregisters keyboard actions.protected voidUnregisters listeners.Methods declared in class javax.swing.plaf.ComponentUIcontains, getAccessibleChild, getAccessibleChildrenCount, getPreferredSize, installUI, uninstallUI, update
- 
Field Details- 
labelUIThe defaultBasicLabelUIinstance. This field might not be used. To change the default instance use a subclass which overrides thecreateUImethod, and place that class name in defaults table under the key "LabelUI".
 
- 
- 
Constructor Details- 
BasicLabelUIpublic BasicLabelUI()Constructs aBasicLabelUI.
 
- 
- 
Method Details- 
layoutCLprotected String layoutCL(JLabel label, FontMetrics fontMetrics, String text, Icon icon, Rectangle viewR, Rectangle iconR, Rectangle textR) Forwards the call to SwingUtilities.layoutCompoundLabel(). This method is here so that a subclass could do Label specific layout and to shorten the method name a little.- Parameters:
- label- an instance of- JLabel
- fontMetrics- a font metrics
- text- a text
- icon- an icon
- viewR- a bounding rectangle to lay out label
- iconR- a bounding rectangle to lay out icon
- textR- a bounding rectangle to lay out text
- Returns:
- a possibly clipped version of the compound labels string
- See Also:
 
- 
paintEnabledText
- 
paintDisabledTextPaint clippedText at textX, textY with background.lighter() and then shifted down and to the right by one pixel with background.darker().- Parameters:
- l- an instance of- JLabel
- g- an instance of- Graphics
- s- a text
- textX- an X coordinate
- textY- an Y coordinate
- See Also:
 
- 
paintPaints the label text with the foreground color, if the label is opaque then paints the entire background with the background color. The Label text is drawn bypaintEnabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int)orpaintDisabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int). The locations of the label parts are computed bylayoutCL(javax.swing.JLabel, java.awt.FontMetrics, java.lang.String, javax.swing.Icon, java.awt.Rectangle, java.awt.Rectangle, java.awt.Rectangle).- Overrides:
- paintin class- ComponentUI
- Parameters:
- g- the- Graphicscontext 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
- See Also:
 
- 
getMinimumSizeDescription copied from class:ComponentUIReturns the specified component's minimum size appropriate for the look and feel. Ifnullis 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 invokesgetPreferredSizeand returns that value.- Overrides:
- getMinimumSizein class- ComponentUI
- Parameters:
- 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
- Returns:
- getPreferredSize(c)
- See Also:
 
- 
getMaximumSizeDescription copied from class:ComponentUIReturns the specified component's maximum size appropriate for the look and feel. Ifnullis 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 invokesgetPreferredSizeand returns that value.- Overrides:
- getMaximumSizein class- ComponentUI
- Parameters:
- 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
- Returns:
- getPreferredSize(c)
- See Also:
 
- 
getBaselineReturns the baseline.- Overrides:
- getBaselinein class- ComponentUI
- Parameters:
- c-- JComponentbaseline is being requested for
- width- the width to get the baseline for
- height- the height to get the baseline for
- Returns:
- baseline or a value < 0 indicating there is no reasonable baseline
- Throws:
- NullPointerException- if- cis- null
- IllegalArgumentException- if width or height is < 0
- Since:
- 1.6
- See Also:
 
- 
getBaselineResizeBehaviorReturns an enum indicating how the baseline of the component changes as the size changes.- Overrides:
- getBaselineResizeBehaviorin class- ComponentUI
- Parameters:
- c-- JComponentto return baseline resize behavior for
- Returns:
- an enum indicating how the baseline changes as the component size changes
- Throws:
- NullPointerException- if- cis- null
- Since:
- 1.6
- See Also:
 
- 
installDefaultsInstalls default properties.- Parameters:
- c- an instance of- JLabel
 
- 
installListenersRegisters listeners.- Parameters:
- c- an instance of- JLabel
 
- 
installComponentsRegisters components.- Parameters:
- c- an instance of- JLabel
 
- 
installKeyboardActionsRegisters keyboard actions.- Parameters:
- l- an instance of- JLabel
 
- 
uninstallDefaultsUninstalls default properties.- Parameters:
- c- an instance of- JLabel
 
- 
uninstallListenersUnregisters listeners.- Parameters:
- c- an instance of- JLabel
 
- 
uninstallComponentsUnregisters components.- Parameters:
- c- an instance of- JLabel
 
- 
uninstallKeyboardActionsUnregisters keyboard actions.- Parameters:
- c- an instance of- JLabel
 
- 
createUIReturns an instance ofBasicLabelUI.- Parameters:
- c- a component
- Returns:
- an instance of BasicLabelUI
 
- 
propertyChangeDescription copied from interface:PropertyChangeListenerThis method gets called when a bound property is changed.- Specified by:
- propertyChangein interface- PropertyChangeListener
- Parameters:
- e- A PropertyChangeEvent object describing the event source and the property that has changed.
 
 
-