< prev index next >
src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java
Print this page
*** 34,43 ****
--- 34,45 ----
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
+ import javax.swing.plaf.TextUIDrawing;
+ import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicLabelUI;
*** 52,61 ****
--- 54,64 ----
* long term persistence.
*/
public class WindowsLabelUI extends BasicLabelUI {
private static final Object WINDOWS_LABEL_UI_KEY = new Object();
+ private TextUIDrawing textUIDrawing;
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
*** 67,86 ****
appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI);
}
return windowsLabelUI;
}
protected void paintEnabledText(JLabel l, Graphics g, String s,
int textX, int textY) {
int mnemonicIndex = l.getDisplayedMnemonicIndex();
// W2K Feature: Check to see if the Underscore should be rendered.
if (WindowsLookAndFeel.isMnemonicHidden() == true) {
mnemonicIndex = -1;
}
g.setColor(l.getForeground());
! SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex,
textX, textY);
}
protected void paintDisabledText(JLabel l, Graphics g, String s,
int textX, int textY) {
--- 70,104 ----
appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI);
}
return windowsLabelUI;
}
+ @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(JLabel l, Graphics g, String s,
int textX, int textY) {
int mnemonicIndex = l.getDisplayedMnemonicIndex();
// W2K Feature: Check to see if the Underscore should be rendered.
if (WindowsLookAndFeel.isMnemonicHidden() == true) {
mnemonicIndex = -1;
}
g.setColor(l.getForeground());
! textUIDrawing.drawStringUnderlineCharAt(l, g, s, mnemonicIndex,
textX, textY);
}
protected void paintDisabledText(JLabel l, Graphics g, String s,
int textX, int textY) {
*** 90,112 ****
mnemonicIndex = -1;
}
if ( UIManager.getColor("Label.disabledForeground") instanceof Color &&
UIManager.getColor("Label.disabledShadow") instanceof Color) {
g.setColor( UIManager.getColor("Label.disabledShadow") );
! SwingUtilities2.drawStringUnderlineCharAt(l, g, s,
mnemonicIndex,
textX + 1, textY + 1);
g.setColor( UIManager.getColor("Label.disabledForeground") );
! SwingUtilities2.drawStringUnderlineCharAt(l, g, s,
mnemonicIndex,
textX, textY);
} else {
Color background = l.getBackground();
g.setColor(background.brighter());
! SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
textX + 1, textY + 1);
g.setColor(background.darker());
! SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
textX, textY);
}
}
}
--- 108,130 ----
mnemonicIndex = -1;
}
if ( UIManager.getColor("Label.disabledForeground") instanceof Color &&
UIManager.getColor("Label.disabledShadow") instanceof Color) {
g.setColor( UIManager.getColor("Label.disabledShadow") );
! textUIDrawing.drawStringUnderlineCharAt(l, g, s,
mnemonicIndex,
textX + 1, textY + 1);
g.setColor( UIManager.getColor("Label.disabledForeground") );
! textUIDrawing.drawStringUnderlineCharAt(l, g, s,
mnemonicIndex,
textX, textY);
} else {
Color background = l.getBackground();
g.setColor(background.brighter());
! textUIDrawing.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
textX + 1, textY + 1);
g.setColor(background.darker());
! textUIDrawing.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
textX, textY);
}
}
}
< prev index next >