jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicIconFactory.java
author prr
Sat, 19 Sep 2015 15:45:59 -0700
changeset 32865 f9cb6e427f9e
parent 25859 3317bb8137f4
permissions -rw-r--r--
8136783: Run blessed-modifier-order script on java.desktop Reviewed-by: martin, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing.plaf.basic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.plaf.UIResource;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Polygon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
20169
d7fa6d7586c9 8025085: [javadoc] some errors in javax/swing
yan
parents: 5506
diff changeset
    38
 * Factory object that can vend Icons appropriate for the basic L & F.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * the same version of Swing.  As of 1.4, support for long term storage
20458
f2423fb3fd19 8025840: Fix all the doclint warnings about trademark
cl
parents: 20169
diff changeset
    45
 * of all JavaBeans&trade;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * has been added to the <code>java.beans</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @author Georges Saab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
22574
7f8ce0c8c20a 8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents: 20458
diff changeset
    52
@SuppressWarnings("serial") // Same-version serialization only
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
public class BasicIconFactory implements Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static Icon frame_icon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static Icon checkBoxIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static Icon radioButtonIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private static Icon checkBoxMenuItemIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private static Icon radioButtonMenuItemIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static Icon menuItemCheckIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private static Icon menuItemArrowIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private static Icon menuArrowIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    64
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    65
     * Returns a menu item check icon.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    66
     *
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    67
     * @return a menu item check icon
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    68
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public static Icon getMenuItemCheckIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        if (menuItemCheckIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            menuItemCheckIcon = new MenuItemCheckIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        return menuItemCheckIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    76
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    77
     * Returns a menu item arrow icon.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    78
     *
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    79
     * @return a menu item arrow icon
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    80
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public static Icon getMenuItemArrowIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        if (menuItemArrowIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            menuItemArrowIcon = new MenuItemArrowIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        return menuItemArrowIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    88
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    89
     * Returns a menu arrow icon.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    90
     *
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    91
     * @return a menu arrow icon
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
    92
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public static Icon getMenuArrowIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        if (menuArrowIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            menuArrowIcon = new MenuArrowIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        return menuArrowIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   100
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   101
     * Returns a check box icon.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   102
     *
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   103
     * @return a check box icon
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   104
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public static Icon getCheckBoxIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (checkBoxIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            checkBoxIcon = new CheckBoxIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        return checkBoxIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   112
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   113
     * Returns a radio button icon.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   114
     *
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   115
     * @return a radio button icon
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   116
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public static Icon getRadioButtonIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        if (radioButtonIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            radioButtonIcon = new RadioButtonIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        return radioButtonIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   124
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   125
     * Returns a check box menu item icon.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   126
     *
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   127
     * @return a check box menu item icon
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   128
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    public static Icon getCheckBoxMenuItemIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        if (checkBoxMenuItemIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return checkBoxMenuItemIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   136
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   137
     * Returns a radio button menu item icon.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   138
     *
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   139
     * @return a radio button menu item icon
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   140
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public static Icon getRadioButtonMenuItemIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (radioButtonMenuItemIcon == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        return radioButtonMenuItemIcon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
25761
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   148
    /**
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   149
     * Returns an empty frame icon.
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   150
     *
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   151
     * @return an empty frame icon
c408b10ef757 8043968: Fix doclint warnings from javax.swing.plaf.basic package, 1 of 7
aeremeev
parents: 22574
diff changeset
   152
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public static Icon createEmptyFrameIcon() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        if(frame_icon == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            frame_icon = new EmptyFrameIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        return frame_icon;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    private static class EmptyFrameIcon implements Icon, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        int height = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        int width = 14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        public int getIconWidth() { return width; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        public int getIconHeight() { return height; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    private static class CheckBoxIcon implements Icon, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    {
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 25859
diff changeset
   170
        static final int csize = 13;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            return csize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            return csize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    private static class RadioButtonIcon implements Icon, UIResource, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        public int getIconWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            return 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        public int getIconHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            return 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    } // end class RadioButtonIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    private static class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            AbstractButton b = (AbstractButton) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            boolean isSelected = model.isSelected();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            if (isSelected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                g.drawLine(x+7, y+1, x+7, y+3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                g.drawLine(x+6, y+2, x+6, y+4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                g.drawLine(x+5, y+3, x+5, y+5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                g.drawLine(x+4, y+4, x+4, y+6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                g.drawLine(x+3, y+5, x+3, y+7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                g.drawLine(x+2, y+4, x+2, y+6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                g.drawLine(x+1, y+3, x+1, y+5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        public int getIconWidth() { return 9; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        public int getIconHeight() { return 9; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    } // End class CheckBoxMenuItemIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            AbstractButton b = (AbstractButton) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            ButtonModel model = b.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            if (b.isSelected() == true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                g.fillOval(x+1, y+1, getIconWidth(), getIconHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        public int getIconWidth() { return 6; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        public int getIconHeight() { return 6; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    } // End class RadioButtonMenuItemIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    private static class MenuItemCheckIcon implements Icon, UIResource, Serializable{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        public int getIconWidth() { return 9; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        public int getIconHeight() { return 9; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    } // End class MenuItemCheckIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    private static class MenuItemArrowIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        public int getIconWidth() { return 4; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        public int getIconHeight() { return 8; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    } // End class MenuItemArrowIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    private static class MenuArrowIcon implements Icon, UIResource, Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        public void paintIcon(Component c, Graphics g, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            Polygon p = new Polygon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            p.addPoint(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            p.addPoint(x+getIconWidth(), y+getIconHeight()/2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            p.addPoint(x, y+getIconHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            g.fillPolygon(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        public int getIconWidth() { return 4; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        public int getIconHeight() { return 8; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    } // End class MenuArrowIcon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
}