jdk/test/javax/swing/JColorChooser/Test6559154.java
author goetz
Tue, 09 Dec 2014 11:57:46 +0100
changeset 28187 fc19df82d6ee
parent 5506 202f599c92aa
child 40128 e635645d2a8a
permissions -rw-r--r--
8066964: ppc64: argument and return type profiling, fix problem with popframe Reviewed-by: roland, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1282
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1282
diff changeset
     2
 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
1282
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
     4
 *
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
     8
 *
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    13
 * accompanied this code).
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    14
 *
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1282
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1282
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1282
diff changeset
    21
 * questions.
1282
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    22
 */
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    23
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    24
/*
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    25
 * @test
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    26
 * @bug 6559154
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    27
 * @summary Tests EDT hanging
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    28
 * @author Sergey Malenkov
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    29
 */
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    30
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    31
import java.awt.Component;
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    32
import java.awt.Container;
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    33
import java.awt.event.ActionEvent;
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    34
import java.awt.event.ActionListener;
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    35
import javax.swing.JColorChooser;
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    36
import javax.swing.JDialog;
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    37
import javax.swing.SwingUtilities;
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    38
import javax.swing.Timer;
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    39
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    40
public class Test6559154 implements ActionListener, Runnable {
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    41
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    42
    private JDialog dialog;
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    43
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    44
    public void actionPerformed(ActionEvent event) {
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    45
        if (this.dialog != null) {
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    46
            this.dialog.dispose();
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    47
        }
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    48
    }
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    49
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    50
    public void run() {
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    51
        Timer timer = new Timer(1000, this);
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    52
        timer.setRepeats(false);
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    53
        timer.start();
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    54
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    55
        JColorChooser chooser = new JColorChooser();
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    56
        setEnabledRecursive(chooser, false);
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    57
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    58
        this.dialog = new JDialog();
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    59
        this.dialog.add(chooser);
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    60
        this.dialog.setVisible(true);
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    61
    }
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    62
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    63
    private static void setEnabledRecursive(Container container, boolean enabled) {
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    64
        for (Component component : container.getComponents()) {
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    65
            component.setEnabled(enabled);
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    66
            if (component instanceof Container) {
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    67
                setEnabledRecursive((Container) component, enabled);
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    68
            }
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    69
        }
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    70
    }
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    71
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    72
    public static void main(String[] args) throws Exception {
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    73
        SwingUtilities.invokeAndWait(new Test6559154());
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    74
    }
00a51b36c173 6552812: Add HSL tab to JColorChooser
malenkov
parents:
diff changeset
    75
}