bug8046391.java revision 10730:07156012ab78
198944Sobrien/* 298944Sobrien * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 398944Sobrien * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 498944Sobrien * 598944Sobrien * This code is free software; you can redistribute it and/or modify it 698944Sobrien * under the terms of the GNU General Public License version 2 only, as 798944Sobrien * published by the Free Software Foundation. 898944Sobrien * 998944Sobrien * This code is distributed in the hope that it will be useful, but WITHOUT 1098944Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1198944Sobrien * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1298944Sobrien * version 2 for more details (a copy is included in the LICENSE file that 1398944Sobrien * accompanied this code). 1498944Sobrien * 1598944Sobrien * You should have received a copy of the GNU General Public License version 1698944Sobrien * 2 along with this work; if not, write to the Free Software Foundation, 1798944Sobrien * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1898944Sobrien * 1998944Sobrien * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2098944Sobrien * or visit www.oracle.com if you need additional information or have any 2198944Sobrien * questions. 2298944Sobrien */ 2398944Sobrien 2498944Sobrien/* 25130803Smarcel * @test 2698944Sobrien * @bug 8046391 2798944Sobrien * @summary JFileChooser hangs if displayed in Windows L&F 2898944Sobrien * @author Alexey Ivanov 2998944Sobrien * @library ../../../../lib/testlibrary 3098944Sobrien * @build jdk.testlibrary.OSInfo 3198944Sobrien * @run main/othervm/timeout=10 bug8046391 32130803Smarcel*/ 33130803Smarcel 34130803Smarcelimport com.sun.java.swing.plaf.windows.WindowsLookAndFeel; 35130803Smarcelimport jdk.testlibrary.OSInfo; 36130803Smarcelimport jdk.testlibrary.OSInfo.OSType; 37130803Smarcel 3898944Sobrienimport javax.swing.JFileChooser; 3998944Sobrienimport javax.swing.SwingUtilities; 4098944Sobrienimport javax.swing.UIManager; 4198944Sobrienimport javax.swing.UnsupportedLookAndFeelException; 4298944Sobrien 4398944Sobrienpublic class bug8046391 { 4498944Sobrien 4598944Sobrien public static void main(String[] args) throws Exception { 4698944Sobrien OSType type = OSInfo.getOSType(); 4798944Sobrien if (type != OSType.WINDOWS) { 4898944Sobrien System.out.println("This test is for Windows only... skipping!"); 4998944Sobrien return; 5098944Sobrien } 5198944Sobrien 5298944Sobrien SwingUtilities.invokeAndWait(() -> { 5398944Sobrien try { 5498944Sobrien UIManager.setLookAndFeel(new WindowsLookAndFeel()); 5598944Sobrien } catch (UnsupportedLookAndFeelException e) { 5698944Sobrien e.printStackTrace(); 5798944Sobrien } 5898944Sobrien System.out.println("Creating JFileChooser..."); 5998944Sobrien JFileChooser fileChooser = new JFileChooser(); 6098944Sobrien System.out.println("Test passed: chooser = " + fileChooser); 61130803Smarcel }); 6298944Sobrien // Test fails if creating JFileChooser hangs 6398944Sobrien } 6498944Sobrien 6598944Sobrien} 6698944Sobrien