1740N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1740N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1740N/A *
1740N/A * This code is free software; you can redistribute it and/or modify it
1740N/A * under the terms of the GNU General Public License version 2 only, as
1740N/A * published by the Free Software Foundation.
1740N/A *
1740N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1740N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1740N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1740N/A * version 2 for more details (a copy is included in the LICENSE file that
1740N/A * accompanied this code).
1740N/A *
1740N/A * You should have received a copy of the GNU General Public License version
1740N/A * 2 along with this work; if not, write to the Free Software Foundation,
1740N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1740N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1740N/A */
1740N/A
1740N/A/* @test
1740N/A * @bug 6489130
1740N/A * @summary FileChooserDemo hung by keeping pressing Enter key
1740N/A * @author Pavel Porvatov
1740N/A @run main bug6489130
1740N/A */
1740N/A
1740N/Aimport javax.swing.*;
1740N/Aimport java.awt.*;
1740N/Aimport java.awt.event.ActionEvent;
1740N/Aimport java.awt.event.ActionListener;
1740N/Aimport java.util.concurrent.CountDownLatch;
1740N/Aimport java.util.concurrent.TimeUnit;
1740N/A
1740N/Apublic class bug6489130 {
1740N/A private final JFileChooser chooser = new JFileChooser();
1740N/A
1740N/A private static final CountDownLatch MUX = new CountDownLatch(1);
1740N/A
1740N/A private final Timer timer = new Timer(1000, new ActionListener() {
1740N/A public void actionPerformed(ActionEvent e) {
1740N/A switch (state) {
1740N/A case 0:
1740N/A case 1: {
1740N/A SwingUtilities.invokeLater(new Runnable() {
1740N/A public void run() {
1740N/A chooser.showOpenDialog(null);
1740N/A }
1740N/A });
1740N/A
1740N/A break;
1740N/A }
1740N/A
1740N/A case 2:
1740N/A case 3: {
1740N/A Window[] windows = Frame.getWindows();
1740N/A
1740N/A if (windows.length > 0) {
1740N/A windows[0].dispose();
1740N/A }
1740N/A
1740N/A break;
1740N/A }
1740N/A
1740N/A case 4: {
1740N/A MUX.countDown();
1740N/A
1740N/A break;
1740N/A }
1740N/A }
1740N/A
1740N/A state++;
1740N/A }
1740N/A });
1740N/A
1740N/A private int state = 0;
1740N/A
1740N/A public static void main(String[] args) throws InterruptedException {
1740N/A SwingUtilities.invokeLater(new Runnable() {
1740N/A public void run() {
1740N/A new bug6489130().run();
1740N/A }
1740N/A });
1740N/A }
1740N/A
1740N/A private void run() {
1740N/A timer.start();
1740N/A }
1740N/A}