61 public static ComponentUI createUI(JComponent c) { 62 AppContext appContext = AppContext.getAppContext(); 63 WindowsLabelUI windowsLabelUI = 64 (WindowsLabelUI) appContext.get(WINDOWS_LABEL_UI_KEY); 65 if (windowsLabelUI == null) { 66 windowsLabelUI = new WindowsLabelUI(); 67 appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI); 68 } 69 return windowsLabelUI; 70 } 71 72 protected void paintEnabledText(JLabel l, Graphics g, String s, 73 int textX, int textY) { 74 int mnemonicIndex = l.getDisplayedMnemonicIndex(); 75 // W2K Feature: Check to see if the Underscore should be rendered. 76 if (WindowsLookAndFeel.isMnemonicHidden() == true) { 77 mnemonicIndex = -1; 78 } 79 80 g.setColor(l.getForeground()); 81 SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex, 82 textX, textY); 83 } 84 85 protected void paintDisabledText(JLabel l, Graphics g, String s, 86 int textX, int textY) { 87 int mnemonicIndex = l.getDisplayedMnemonicIndex(); 88 // W2K Feature: Check to see if the Underscore should be rendered. 89 if (WindowsLookAndFeel.isMnemonicHidden() == true) { 90 mnemonicIndex = -1; 91 } 92 if ( UIManager.getColor("Label.disabledForeground") instanceof Color && 93 UIManager.getColor("Label.disabledShadow") instanceof Color) { 94 g.setColor( UIManager.getColor("Label.disabledShadow") ); 95 SwingUtilities2.drawStringUnderlineCharAt(l, g, s, 96 mnemonicIndex, 97 textX + 1, textY + 1); 98 g.setColor( UIManager.getColor("Label.disabledForeground") ); 99 SwingUtilities2.drawStringUnderlineCharAt(l, g, s, 100 mnemonicIndex, 101 textX, textY); 102 } else { 103 Color background = l.getBackground(); 104 g.setColor(background.brighter()); 105 SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, 106 textX + 1, textY + 1); 107 g.setColor(background.darker()); 108 SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex, 109 textX, textY); 110 } 111 } 112 } | 61 public static ComponentUI createUI(JComponent c) { 62 AppContext appContext = AppContext.getAppContext(); 63 WindowsLabelUI windowsLabelUI = 64 (WindowsLabelUI) appContext.get(WINDOWS_LABEL_UI_KEY); 65 if (windowsLabelUI == null) { 66 windowsLabelUI = new WindowsLabelUI(); 67 appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI); 68 } 69 return windowsLabelUI; 70 } 71 72 protected void paintEnabledText(JLabel l, Graphics g, String s, 73 int textX, int textY) { 74 int mnemonicIndex = l.getDisplayedMnemonicIndex(); 75 // W2K Feature: Check to see if the Underscore should be rendered. 76 if (WindowsLookAndFeel.isMnemonicHidden() == true) { 77 mnemonicIndex = -1; 78 } 79 80 g.setColor(l.getForeground()); 81 getTextUIDrawing().drawStringUnderlineCharAt(l, g, s, mnemonicIndex, 82 textX, textY); 83 } 84 85 protected void paintDisabledText(JLabel l, Graphics g, String s, 86 int textX, int textY) { 87 int mnemonicIndex = l.getDisplayedMnemonicIndex(); 88 // W2K Feature: Check to see if the Underscore should be rendered. 89 if (WindowsLookAndFeel.isMnemonicHidden() == true) { 90 mnemonicIndex = -1; 91 } 92 if ( UIManager.getColor("Label.disabledForeground") instanceof Color && 93 UIManager.getColor("Label.disabledShadow") instanceof Color) { 94 g.setColor( UIManager.getColor("Label.disabledShadow") ); 95 getTextUIDrawing().drawStringUnderlineCharAt(l, g, s, 96 mnemonicIndex, 97 textX + 1, textY + 1); 98 g.setColor( UIManager.getColor("Label.disabledForeground") ); 99 getTextUIDrawing().drawStringUnderlineCharAt(l, g, s, 100 mnemonicIndex, 101 textX, textY); 102 } else { 103 Color background = l.getBackground(); 104 g.setColor(background.brighter()); 105 getTextUIDrawing().drawStringUnderlineCharAt(l,g, s, mnemonicIndex, 106 textX + 1, textY + 1); 107 g.setColor(background.darker()); 108 getTextUIDrawing().drawStringUnderlineCharAt(l,g, s, mnemonicIndex, 109 textX, textY); 110 } 111 } 112 } |