Path: blob/master/test/jdk/com/sun/java/swing/plaf/gtk/Test6635110.java
41162 views
/*1* Copyright (c) 2008, 2010, 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/* @test24@bug 663511025@key headful26@summary GTK icons should not throw NPE when called by non-GTK UI27@author Peter Zhelezniakov28@run main Test663511029*/3031import javax.swing.*;32import java.awt.*;33import java.awt.image.BufferedImage;34import javax.swing.plaf.basic.*;353637public class Test6635110 implements Runnable {3839static final int WIDTH = 160;40static final int HEIGHT = 80;41final BufferedImage IMAGE =42new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);4344@Override public void run() {45JMenu menu = new JMenu("menu");46menu.setUI(new BasicMenuUI());47paint(menu);4849JToolBar tb = new JToolBar();50tb.setFloatable(true);51tb.setUI(new BasicToolBarUI());52paint(tb);53}5455void paint(Component c) {56c.setSize(WIDTH, HEIGHT);57c.paint(IMAGE.getGraphics());58}5960public static void main(String[] args) throws Exception {61try {62UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");63} catch (Exception e) {64System.out.println("GTKLookAndFeel cannot be set, skipping this test");65return;66}67SwingUtilities.invokeAndWait(new Test6635110());68}69}707172