jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
author mlapshin
Fri, 08 Aug 2008 20:49:26 +0400
changeset 1295 3cf2264a5743
parent 2 90ce3da70b43
child 4394 92a8ec883f5d
permissions -rw-r--r--
6584657: GTK Look and Feel: Bugs in menu item layout Reviewed-by: peterz, alexp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
     2
 * Copyright 2002-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.plaf.synth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.plaf.basic.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.border.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.swing.plaf.synth.SynthUI;
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
    38
import sun.swing.MenuItemLayoutHelper;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Synth's MenuUI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @author Georges Saab
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @author David Karlton
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @author Arnaud Weber
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
class SynthMenuUI extends BasicMenuUI implements PropertyChangeListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                               SynthUI {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private SynthStyle style;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private SynthStyle accStyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private String acceleratorDelimiter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public static ComponentUI createUI(JComponent x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        return new SynthMenuUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        updateStyle(menuItem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    protected void installListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        super.installListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        menuItem.addPropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private void updateStyle(JMenuItem mi) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        SynthStyle oldStyle = style;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        SynthContext context = getContext(mi, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        style = SynthLookAndFeel.updateStyle(context, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        if (oldStyle != style) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            String prefix = getPropertyPrefix();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            defaultTextIconGap = style.getInt(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                           context, prefix + ".textIconGap", 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            if (menuItem.getMargin() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                         (menuItem.getMargin() instanceof UIResource)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                Insets insets = (Insets)style.get(context, prefix + ".margin");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                if (insets == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                    // Some places assume margins are non-null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                    insets = SynthLookAndFeel.EMPTY_UIRESOURCE_INSETS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                menuItem.setMargin(insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            acceleratorDelimiter = style.getString(context, prefix +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                                            ".acceleratorDelimiter", "+");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
    89
            if (MenuItemLayoutHelper.useCheckAndArrow(menuItem)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                checkIcon = style.getIcon(context, prefix + ".checkIcon");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                arrowIcon = style.getIcon(context, prefix + ".arrowIcon");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                // Not needed in this case
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                checkIcon = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                arrowIcon = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            ((JMenu)menuItem).setDelay(style.getInt(context, prefix +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                                                    ".delay", 200));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            if (oldStyle != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                uninstallKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                installKeyboardActions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        SynthContext accContext = getContext(mi, Region.MENU_ITEM_ACCELERATOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                             ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        accStyle = SynthLookAndFeel.updateStyle(accContext, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        accContext.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   114
    public void uninstallUI(JComponent c) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   115
        super.uninstallUI(c);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   116
        // Remove values from the parent's Client Properties.
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   117
        JComponent p = MenuItemLayoutHelper.getMenuItemParent((JMenuItem) c);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   118
        if (p != null) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   119
            p.putClientProperty(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   120
                    SynthMenuItemLayoutHelper.MAX_ACC_OR_ARROW_WIDTH, null);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   121
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   122
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   123
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    protected void uninstallDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        SynthContext context = getContext(menuItem, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        style.uninstallDefaults(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        style = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        SynthContext accContext = getContext(menuItem,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                                     Region.MENU_ITEM_ACCELERATOR, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        accStyle.uninstallDefaults(accContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        accContext.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        accStyle = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        super.uninstallDefaults();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    protected void uninstallListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        super.uninstallListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        menuItem.removePropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    public SynthContext getContext(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        return getContext(c, getComponentState(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    SynthContext getContext(JComponent c, int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        Region region = getRegion(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        return SynthContext.getContext(SynthContext.class, c, region,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                                       style, state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public SynthContext getContext(JComponent c, Region region) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return getContext(c, region, getComponentState(c, region));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    private SynthContext getContext(JComponent c, Region region, int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        return SynthContext.getContext(SynthContext.class, c,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                       region, accStyle, state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    private Region getRegion(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        return SynthLookAndFeel.getRegion(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    private int getComponentState(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        int state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (!c.isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            return DISABLED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if (menuItem.isArmed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            state = MOUSE_OVER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            state = SynthLookAndFeel.getComponentState(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        if (menuItem.isSelected()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            state |= SELECTED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        return state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    private int getComponentState(JComponent c, Region region) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return getComponentState(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    protected Dimension getPreferredMenuItemSize(JComponent c,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                                                     Icon checkIcon,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                                                     Icon arrowIcon,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                                                     int defaultTextIconGap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        SynthContext accContext = getContext(c, Region.MENU_ITEM_ACCELERATOR);
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   195
        Dimension value = SynthGraphicsUtils.getPreferredMenuItemSize(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   196
                context, accContext, c, checkIcon, arrowIcon,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   197
                defaultTextIconGap, acceleratorDelimiter,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   198
                MenuItemLayoutHelper.useCheckAndArrow(menuItem),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   199
                getPropertyPrefix());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        accContext.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    public void update(Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        SynthLookAndFeel.update(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        context.getPainter().paintMenuBackground(context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                          g, 0, 0, c.getWidth(), c.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        paint(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public void paint(Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        paint(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    protected void paint(SynthContext context, Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        SynthContext accContext = getContext(menuItem,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                             Region.MENU_ITEM_ACCELERATOR);
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   226
        // Refetch the appropriate check indicator for the current state
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   227
        String prefix = getPropertyPrefix();
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   228
        Icon checkIcon = style.getIcon(context, prefix + ".checkIcon");
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   229
        Icon arrowIcon = style.getIcon(context, prefix + ".arrowIcon");
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   230
        SynthGraphicsUtils.paint(context, accContext, g, checkIcon, arrowIcon,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents: 2
diff changeset
   231
              acceleratorDelimiter, defaultTextIconGap, getPropertyPrefix());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        accContext.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    public void paintBorder(SynthContext context, Graphics g, int x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                            int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        context.getPainter().paintMenuBorder(context, g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public void propertyChange(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        if (SynthLookAndFeel.shouldUpdateStyle(e)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            updateStyle((JMenu)e.getSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
}