Here you can find the source of paintClassicText(AbstractButton b, Graphics g, int x, int y, String text, int mnemIndex)
static void paintClassicText(AbstractButton b, Graphics g, int x, int y, String text, int mnemIndex)
//package com.java2s; /*/* w w w . j ava2 s . c om*/ * %W% %E% * * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import sun.swing.SwingUtilities2; import java.awt.*; import javax.swing.*; public class Main { static void paintClassicText(AbstractButton b, Graphics g, int x, int y, String text, int mnemIndex) { ButtonModel model = b.getModel(); /* Draw the Text */ Color color = b.getForeground(); if (model.isEnabled()) { /*** paint the text normally */ if (!(b instanceof JMenuItem && model.isArmed()) && !(b instanceof JMenu && (model.isSelected() || model.isRollover()))) { /* We shall not set foreground color for selected menu or * armed menuitem. Foreground must be set in appropriate * Windows* class because these colors passes from * BasicMenuItemUI as protected fields and we can't * reach them from this class */ g.setColor(b.getForeground()); } SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y); } else { /*** paint the text disabled ***/ color = UIManager.getColor("Button.shadow"); Color shadow = UIManager.getColor("Button.disabledShadow"); if (model.isArmed()) { color = UIManager.getColor("Button.disabledForeground"); } else { if (shadow == null) { shadow = b.getBackground().darker(); } g.setColor(shadow); SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x + 1, y + 1); } if (color == null) { color = b.getBackground().brighter(); } g.setColor(color); SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y); } } }