jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
author peterz
Thu, 10 Dec 2009 12:08:58 +0300
changeset 4394 92a8ec883f5d
parent 2 90ce3da70b43
child 4848 ffcc849b9351
permissions -rw-r--r--
6827653: Make Synth UI classes public Reviewed-by: alexp
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 2002-2003 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.synth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.plaf.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.plaf.basic.BasicDesktopIconUI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.beans.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    37
 * Provides the Synth L&F UI delegate for a minimized internal frame on a desktop.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @author Joshua Outwater
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    40
 * @since 1.7
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    42
public class SynthDesktopIconUI extends BasicDesktopIconUI
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    43
                                implements SynthUI, PropertyChangeListener {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private SynthStyle style;
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    45
    private Handler handler = new Handler();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    47
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    48
     * Creates a new UI object for the given component.
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    49
     *
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    50
     * @param c component to create UI object for
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    51
     * @return the UI object
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    52
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public static ComponentUI createUI(JComponent c)    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        return new SynthDesktopIconUI();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    57
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    58
     * @inheritDoc
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    59
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    60
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    protected void installComponents() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        if (UIManager.getBoolean("InternalFrame.useTaskBar")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            iconPane = new JToggleButton(frame.getTitle(), frame.getFrameIcon()) {
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    64
                @Override public String getToolTipText() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                    return getText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    68
                @Override public JPopupMenu getComponentPopupMenu() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                    return frame.getComponentPopupMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            ToolTipManager.sharedInstance().registerComponent(iconPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            iconPane.setFont(desktopIcon.getFont());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            iconPane.setBackground(desktopIcon.getBackground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            iconPane.setForeground(desktopIcon.getForeground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            iconPane = new SynthInternalFrameTitlePane(frame);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            iconPane.setName("InternalFrame.northPane");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        desktopIcon.setLayout(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        desktopIcon.add(iconPane, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    84
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    85
     * @inheritDoc
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    86
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    87
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    protected void installListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        super.installListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        desktopIcon.addPropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        if (iconPane instanceof JToggleButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            frame.addPropertyChangeListener(this);
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    94
            ((JToggleButton)iconPane).addActionListener(handler);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    98
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
    99
     * @inheritDoc
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   100
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   101
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    protected void uninstallListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (iconPane instanceof JToggleButton) {
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   104
            ((JToggleButton)iconPane).removeActionListener(handler);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            frame.removePropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        desktopIcon.removePropertyChangeListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        super.uninstallListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   111
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   112
     * @inheritDoc
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   113
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   114
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected void installDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        updateStyle(desktopIcon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private void updateStyle(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        SynthContext context = getContext(c, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        style = SynthLookAndFeel.updateStyle(context, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   125
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   126
     * @inheritDoc
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   127
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   128
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    protected void uninstallDefaults() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        SynthContext context = getContext(desktopIcon, ENABLED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        style.uninstallDefaults(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        style = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   136
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   137
     * @inheritDoc
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   138
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   139
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public SynthContext getContext(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return getContext(c, getComponentState(c));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    private SynthContext getContext(JComponent c, int state) {
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   145
        Region region = SynthLookAndFeel.getRegion(c);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        return SynthContext.getContext(SynthContext.class, c, region,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                                       style, state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    private int getComponentState(JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return SynthLookAndFeel.getComponentState(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   154
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   155
     * @inheritDoc
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   156
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   157
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public void update(Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        SynthLookAndFeel.update(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        context.getPainter().paintDesktopIconBackground(context, g, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                                                  c.getWidth(), c.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        paint(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   168
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   169
     * @inheritDoc
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   170
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   171
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public void paint(Graphics g, JComponent c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        SynthContext context = getContext(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        paint(context, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   179
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   180
     * Paints the specified component. This implementation does nothing.
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   181
     *
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   182
     * @param context context for the component being painted
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   183
     * @param g {@code Graphics} object used for painting
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   184
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    protected void paint(SynthContext context, Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   188
    /**
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   189
     * @inheritDoc
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   190
     */
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   191
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    public void paintBorder(SynthContext context, Graphics g, int x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                            int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        context.getPainter().paintDesktopIconBorder(context, g, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public void propertyChange(PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if (evt.getSource() instanceof JInternalFrame.JDesktopIcon) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                updateStyle((JInternalFrame.JDesktopIcon)evt.getSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        } else if (evt.getSource() instanceof JInternalFrame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            JInternalFrame frame = (JInternalFrame)evt.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            if (iconPane instanceof JToggleButton) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                JToggleButton button = (JToggleButton)iconPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                String prop = evt.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                if (prop == "title") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                    button.setText((String)evt.getNewValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                } else if (prop == "frameIcon") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                    button.setIcon((Icon)evt.getNewValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                } else if (prop == JInternalFrame.IS_ICON_PROPERTY ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                           prop == JInternalFrame.IS_SELECTED_PROPERTY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    button.setSelected(!frame.isIcon() && frame.isSelected());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
4394
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   218
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   219
    private final class Handler implements ActionListener {
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   220
        public void actionPerformed(ActionEvent evt) {
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   221
            if (evt.getSource() instanceof JToggleButton) {
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   222
                // Either iconify the frame or deiconify and activate it.
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   223
                JToggleButton button = (JToggleButton)evt.getSource();
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   224
                try {
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   225
                    boolean selected = button.isSelected();
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   226
                    if (!selected && !frame.isIconifiable()) {
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   227
                        button.setSelected(true);
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   228
                    } else {
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   229
                        frame.setIcon(!selected);
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   230
                        if (selected) {
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   231
                            frame.setSelected(true);
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   232
                        }
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   233
                    }
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   234
                } catch (PropertyVetoException e2) {
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   235
                }
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   236
            }
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   237
        }
92a8ec883f5d 6827653: Make Synth UI classes public
peterz
parents: 2
diff changeset
   238
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
}