Java JButton Settings paintClassicText(AbstractButton b, Graphics g, int x, int y, String text, int mnemIndex)

Here you can find the source of paintClassicText(AbstractButton b, Graphics g, int x, int y, String text, int mnemIndex)

Description

paint Classic Text

License

Open Source License

Declaration

static void paintClassicText(AbstractButton b, Graphics g, int x, int y, String text, int mnemIndex) 

Method Source Code


//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);
        }
    }
}

Related

  1. isSelected(final AbstractButton abstractButton)
  2. lookupButton(Container c, String text)
  3. newTabbedPaneButton(String text)
  4. numberButtonGroup(ButtonGroup buttonGroup)
  5. opacityCheck(AbstractButton b)
  6. parseLevel(ButtonGroup buttonGroup)
  7. removeAllActionListeners(AbstractButton btn)
  8. removeButtonBorder(AbstractButton button)
  9. removeCloseButton(Component comp)