1 7 8 package com.sun.java.swing.plaf.windows; 9 10 import com.sun.java.swing.SwingUtilities2; 11 import java.awt.Color ; 12 import java.awt.Graphics ; 13 14 import javax.swing.JComponent ; 15 import javax.swing.JLabel ; 16 import javax.swing.UIManager ; 17 18 import javax.swing.plaf.ComponentUI ; 19 20 import javax.swing.plaf.basic.BasicLabelUI ; 21 22 23 24 34 public class WindowsLabelUI extends BasicLabelUI { 35 36 private final static WindowsLabelUI windowsLabelUI = new WindowsLabelUI(); 37 38 public static ComponentUI createUI(JComponent c){ 42 return windowsLabelUI; 43 } 44 45 protected void paintEnabledText(JLabel l, Graphics g, String s, 46 int textX, int textY) { 47 int mnemonicIndex = l.getDisplayedMnemonicIndex(); 48 if (WindowsLookAndFeel.isMnemonicHidden() == true) { 50 mnemonicIndex = -1; 51 } 52 53 g.setColor(l.getForeground()); 54 SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, 55 textX, textY); 56 } 57 58 protected void paintDisabledText(JLabel l, Graphics g, String s, 59 int textX, int textY) { 60 int mnemonicIndex = l.getDisplayedMnemonicIndex(); 61 if (WindowsLookAndFeel.isMnemonicHidden() == true) { 63 mnemonicIndex = -1; 64 } 65 if ( UIManager.getColor("Label.disabledForeground") instanceof Color && 66 UIManager.getColor("Label.disabledShadow") instanceof Color ) { 67 g.setColor( UIManager.getColor("Label.disabledShadow") ); 68 SwingUtilities2.drawStringUnderlineCharAt(l, g, s, 69 mnemonicIndex, 70 textX + 1, textY + 1); 71 g.setColor( UIManager.getColor("Label.disabledForeground") ); 72 SwingUtilities2.drawStringUnderlineCharAt(l, g, s, 73 mnemonicIndex, 74 textX, textY); 75 } else { 76 Color background = l.getBackground(); 77 g.setColor(background.brighter()); 78 SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, 79 textX + 1, textY + 1); 80 g.setColor(background.darker()); 81 SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, 82 textX, textY); 83 } 84 } 85 } 86 87 | Popular Tags |