Path: blob/master/test/jdk/javax/swing/JTable/Test6888156.java
41152 views
/*1* Copyright (c) 2007, 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 688815625@summary Tests table column of class Icon.class with Synth LAF26@author Peter Zhelezniakov27@run main Test688815628*/2930import java.awt.Component;31import java.awt.Graphics;32import java.awt.image.BufferedImage;33import javax.swing.*;34import javax.swing.table.AbstractTableModel;35import javax.swing.table.TableModel;3637public class Test6888156 {38private JTable table;39private Icon ICON = new Icon() {40@Override public int getIconWidth() {41return 24;42}4344@Override public int getIconHeight() {45return 24;46}4748@Override public void paintIcon(Component c, Graphics g, int w, int h) {49}50};5152public Test6888156() {53TableModel model = new AbstractTableModel() {54@Override public int getRowCount() {55return 3;56}5758@Override public int getColumnCount() {59return 2;60}6162@Override public Object getValueAt(int rowIndex, int columnIndex) {63return (columnIndex == 1 ? ICON : 4);64}6566@Override public Class<?> getColumnClass(int columnIndex) {67return (columnIndex == 1 ? Icon.class : int.class);68}69};70table = new JTable(model);71}7273public void test(final String laf) throws Exception {74SwingUtilities.invokeAndWait(new Runnable() {75@Override public void run() {76try {77System.out.println(laf);78UIManager.setLookAndFeel(laf);79} catch (Exception e) {80System.err.println(laf + " is unsupported; continuing");81return;82}83SwingUtilities.updateComponentTreeUI(table);84table.setSize(100, 100);85table.paint(86new BufferedImage(100, 100, BufferedImage.OPAQUE).87getGraphics());88}89});90}9192public static void main(String[] args) throws Exception {93Test6888156 t = new Test6888156();94t.test("javax.swing.plaf.nimbus.NimbusLookAndFeel");95t.test("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");96for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {97t.test(laf.getClassName());98}99}100}101102103