Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java
38918 views
/*1* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24@test25@summary Tests that GTK LaF is supported on solaris26regardless of jdk.gtk.version flag values.27@bug 815612128@requires (os.name == "linux" | os.name == "solaris")29@run main/othervm -Djdk.gtk.version=2 DemandGTK30@run main/othervm -Djdk.gtk.version=3 DemandGTK31*/3233import javax.swing.JFrame;34import javax.swing.UIManager;35import javax.swing.SwingUtilities;36import java.awt.Robot;3738public class DemandGTK {3940static JFrame frame;41public static void createAndShow() {42try {43UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");44} catch(Exception cnf) {45cnf.printStackTrace();46throw new RuntimeException("GTK LaF must be supported");47}48frame = new JFrame("JFrame");49frame.setSize(200, 200);5051frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);52frame.setVisible(true);53}5455/**56* @param args the command line arguments57*/58public static void main(String[] args) throws Exception {59SwingUtilities.invokeAndWait(DemandGTK::createAndShow);60Robot robot = new Robot();61robot.waitForIdle();62robot.delay(1000);63SwingUtilities.invokeAndWait( () -> {64frame.setVisible(false);65frame.dispose();66});6768}69}707172