< prev index next >
src/java.desktop/macosx/classes/com/apple/laf/AquaLabelUI.java
Print this page
@@ -36,10 +36,11 @@
import com.apple.laf.AquaUtils.RecyclableSingleton;
import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
public class AquaLabelUI extends BasicLabelUI {
protected static final RecyclableSingleton<AquaLabelUI> aquaLabelUI = new RecyclableSingletonFromDefaultConstructor<AquaLabelUI>(AquaLabelUI.class);
+ private TextUIDrawing textUIDrawing;
public static ComponentUI createUI(final JComponent c) {
return aquaLabelUI.get();
}
@@ -51,18 +52,33 @@
protected void uninstallListeners(final JLabel c) {
AquaUtilControlSize.removeSizePropertyListener(c);
super.uninstallListeners(c);
}
+ @Override
+ protected void installDefaults(JLabel c) {
+ super.installDefaults(c);
+ textUIDrawing = SwingUtilities2.getTextUIDrawing(textUIDrawing);
+ }
+
+ @Override
+ protected void uninstallDefaults(JLabel c) {
+ super.uninstallDefaults(c);
+ if (textUIDrawing != SwingUtilities2.DEFAULT_UI_TEXT_DRAWING
+ && textUIDrawing instanceof UIResource) {
+ textUIDrawing = SwingUtilities2.DEFAULT_UI_TEXT_DRAWING;
+ }
+ }
+
protected void paintEnabledText(final JLabel l, final Graphics g, final String s, final int textX, final int textY) {
int mnemIndex = l.getDisplayedMnemonicIndex();
if (AquaMnemonicHandler.isMnemonicHidden()) {
mnemIndex = -1;
}
g.setColor(l.getForeground());
- SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX, textY);
+ textUIDrawing.drawStringUnderlineCharAt(l, g, s, mnemIndex, textX, textY);
}
/**
* Paint clippedText at textX, textY with background.lighter() and then
* shifted down and to the right by one pixel with background.darker().
@@ -79,11 +95,11 @@
final Color background = l.getBackground();
// if our background is still something we set then we can use our happy background color.
if (background instanceof UIResource) {
g.setColor(getDisabledLabelColor(l));
- SwingUtilities2.drawStringUnderlineCharAt(l, g, s, accChar, textX, textY);
+ textUIDrawing.drawStringUnderlineCharAt(l, g, s, accChar, textX, textY);
} else {
super.paintDisabledText(l, g, s, textX, textY);
}
}
< prev index next >