Path: blob/master/test/jdk/javax/swing/JTable/8031971/bug8031971.java
41154 views
/*1* Copyright (c) 2014, 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*/22import java.util.Date;23import java.util.Hashtable;24import javax.swing.Icon;25import javax.swing.ImageIcon;26import javax.swing.JTable;27import javax.swing.SwingUtilities;2829/**30* @test31* @bug 8031971 803975032* @author Alexander Scherbatiy33* @summary Use only public methods in the SwingLazyValue34* @run main/othervm bug803197135*/36public class bug8031971 {3738static Object[][] RENDERERS = {39{Object.class, "javax.swing.table.DefaultTableCellRenderer$UIResource"},40{Number.class, "javax.swing.JTable$NumberRenderer"},41{Float.class, "javax.swing.JTable$DoubleRenderer"},42{Double.class, "javax.swing.JTable$DoubleRenderer"},43{Date.class, "javax.swing.JTable$DateRenderer"},44{Icon.class, "javax.swing.JTable$IconRenderer"},45{ImageIcon.class, "javax.swing.JTable$IconRenderer"},46{Boolean.class, "javax.swing.JTable$BooleanRenderer"}47};4849static Object[][] EDITORS = {50{Object.class, "javax.swing.JTable$GenericEditor"},51{Number.class, "javax.swing.JTable$NumberEditor"},52{Boolean.class, "javax.swing.JTable$BooleanEditor"}53};5455public static void main(String[] args) throws Exception {5657SwingUtilities.invokeAndWait(() -> {5859TestTable table = new TestTable();60test(table.getDefaultRenderersByColumnClass(), RENDERERS);61test(table.getDefaultEditorsByColumnClass(), EDITORS);62});63}6465static void test(Hashtable table, Object[][] values) {66for (int i = 0; i < values.length; i++) {67test(table.get(values[i][0]), (String) values[i][1]);68}69}7071static void test(Object obj, String className) {72if (!obj.getClass().getCanonicalName().equals(className.replace('$', '.'))) {73throw new RuntimeException("Wrong value!");74}75}7677static class TestTable extends JTable {7879Hashtable getDefaultRenderersByColumnClass() {80return defaultRenderersByColumnClass;81}8283Hashtable getDefaultEditorsByColumnClass() {84return defaultEditorsByColumnClass;85}86}87}888990