MetalLabelUI (Java Platform SE 8 )
Keywords: javax.swing.plaf.metal.MetalLabelUI class
Date: 2026-06-25

javax.swing.plaf.metal

## Class MetalLabelUI

- java.lang.Object
- - javax.swing.plaf.ComponentUI
  - - javax.swing.plaf.LabelUI
    - - javax.swing.plaf.basic.BasicLabelUI
      - - javax.swing.plaf.metal.MetalLabelUI

- All Implemented Interfaces:
    PropertyChangeListener, EventListener

      public class MetalLabelUI
      extends BasicLabelUI

  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 Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static MetalLabelUI` | `metalLabelUI` The default `MetalLabelUI` instance.

    - ### Fields inherited from class javax.swing.plaf.basic.BasicLabelUI

      `labelUI`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MetalLabelUI()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ComponentUI` | `createUI(JComponent c)`
    `protected void` | `paintDisabledText(JLabel l, Graphics g, String s, int textX, int textY)` Just paint the text gray (Label.disabledForeground) rather than in the labels foreground color.

    - ### Methods inherited from class javax.swing.plaf.basic.BasicLabelUI

      `getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installComponents, installDefaults, installKeyboardActions, installListeners, installUI, layoutCL, paint, paintEnabledText, propertyChange, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI`

    - ### Methods inherited from class javax.swing.plaf.ComponentUI

      `contains, getAccessibleChild, getAccessibleChildrenCount, update`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### metalLabelUI

          protected static MetalLabelUI metalLabelUI

      The default `MetalLabelUI` 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".

  - ### Constructor Detail

    - #### MetalLabelUI

          public MetalLabelUI()

  - ### Method Detail

    - #### createUI

          public static ComponentUI createUI(JComponent c)

    - #### paintDisabledText

          protected void paintDisabledText(JLabel l,
                                           Graphics g,
                                           String s,
                                           int textX,
                                           int textY)

      Just paint the text gray (Label.disabledForeground) rather than in the labels foreground color.
      Overrides:
        `paintDisabledText` in class `BasicLabelUI`
      Parameters:
        `l` - an instance of `JLabel`
        `g` - an instance of `Graphics`
        `s` - a text
        `textX` - an X coordinate
        `textY` - an Y coordinate
      See Also:
        `BasicLabelUI.paint(java.awt.Graphics, javax.swing.JComponent)`, `BasicLabelUI.paintEnabledText(javax.swing.JLabel, java.awt.Graphics, java.lang.String, int, int)`

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.