jdk/src/share/classes/javax/swing/plaf/basic/BasicRootPaneUI.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
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 java.awt.event.ActionEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.KeyboardFocusManager;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.swing.DefaultLookup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.swing.UIAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Basic implementation of RootPaneUI, there is one shared between all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * JRootPane instances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @author Scott Violet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
public class BasicRootPaneUI extends RootPaneUI implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                  PropertyChangeListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private static RootPaneUI rootPaneUI = new BasicRootPaneUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public static ComponentUI createUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        return rootPaneUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public void installUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        installDefaults((JRootPane)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        installComponents((JRootPane)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        installListeners((JRootPane)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        installKeyboardActions((JRootPane)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public void uninstallUI(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        uninstallDefaults((JRootPane)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        uninstallComponents((JRootPane)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        uninstallListeners((JRootPane)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        uninstallKeyboardActions((JRootPane)c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    protected void installDefaults(JRootPane c){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        LookAndFeel.installProperty(c, "opaque", Boolean.FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    protected void installComponents(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    protected void installListeners(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        root.addPropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    protected void installKeyboardActions(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        InputMap km = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, root);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        SwingUtilities.replaceUIInputMap(root,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                JComponent.WHEN_IN_FOCUSED_WINDOW, km);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        km = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                root);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        SwingUtilities.replaceUIInputMap(root,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, km);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        LazyActionMap.installLazyActionMap(root, BasicRootPaneUI.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                "RootPane.actionMap");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        updateDefaultButtonBindings(root);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    protected void uninstallDefaults(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    protected void uninstallComponents(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    protected void uninstallListeners(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        root.removePropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    protected void uninstallKeyboardActions(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        SwingUtilities.replaceUIInputMap(root, JComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                                       WHEN_IN_FOCUSED_WINDOW, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        SwingUtilities.replaceUIActionMap(root, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    InputMap getInputMap(int condition, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            return (InputMap)DefaultLookup.get(c, this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                                       "RootPane.ancestorInputMap");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            return createInputMap(condition, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    ComponentInputMap createInputMap(int condition, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        return new RootPaneInputMap(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    static void loadActionMap(LazyActionMap map) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        map.put(new Actions(Actions.PRESS));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        map.put(new Actions(Actions.RELEASE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        map.put(new Actions(Actions.POST_POPUP));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Invoked when the default button property has changed. This reloads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * the bindings from the defaults table with name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * <code>RootPane.defaultButtonWindowKeyBindings</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    void updateDefaultButtonBindings(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        InputMap km = SwingUtilities.getUIInputMap(root, JComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                                               WHEN_IN_FOCUSED_WINDOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        while (km != null && !(km instanceof RootPaneInputMap)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            km = km.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (km != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            km.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            if (root.getDefaultButton() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                Object[] bindings = (Object[])DefaultLookup.get(root, this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                           "RootPane.defaultButtonWindowKeyBindings");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                if (bindings != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                    LookAndFeel.loadKeyBindings(km, bindings);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Invoked when a property changes on the root pane. If the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * indicates the <code>defaultButton</code> has changed, this will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * reinstall the keyboard actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public void propertyChange(PropertyChangeEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        if(e.getPropertyName().equals("defaultButton")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            JRootPane rootpane = (JRootPane)e.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            updateDefaultButtonBindings(rootpane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            if (rootpane.getClientProperty("temporaryDefaultButton") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                rootpane.putClientProperty("initialDefaultButton", e.getNewValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    static class Actions extends UIAction {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        public static final String PRESS = "press";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        public static final String RELEASE = "release";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        public static final String POST_POPUP = "postPopup";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        Actions(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            JRootPane root = (JRootPane)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            JButton owner = root.getDefaultButton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            String key = getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            if (key == POST_POPUP) { // Action to post popup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                Component c = KeyboardFocusManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                        .getCurrentKeyboardFocusManager()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                         .getFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                if(c instanceof JComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    JComponent src = (JComponent) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    JPopupMenu jpm = src.getComponentPopupMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    if(jpm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                        Point pt = src.getPopupLocation(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                        if(pt == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                            Rectangle vis = src.getVisibleRect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                            pt = new Point(vis.x+vis.width/2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                                           vis.y+vis.height/2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                        jpm.show(c, pt.x, pt.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            else if (owner != null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                     && SwingUtilities.getRootPane(owner) == root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                if (key == PRESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                    owner.doClick(20);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        public boolean isEnabled(Object sender) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            String key = getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            if(key == POST_POPUP) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                MenuElement[] elems = MenuSelectionManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                        .defaultManager()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                        .getSelectedPath();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                if(elems != null && elems.length != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                    // We shall not interfere with already opened menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                Component c = KeyboardFocusManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                       .getCurrentKeyboardFocusManager()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                        .getFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                if(c instanceof JComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                    JComponent src = (JComponent) c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                    return src.getComponentPopupMenu() != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            if (sender != null && sender instanceof JRootPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                JButton owner = ((JRootPane)sender).getDefaultButton();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                return (owner != null && owner.getModel().isEnabled());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    private static class RootPaneInputMap extends ComponentInputMapUIResource {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        public RootPaneInputMap(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            super(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
}