jdk/test/javax/swing/JTable/Test6888156.java
author malenkov
Mon, 27 Sep 2010 21:07:45 +0400
changeset 6659 8add9a1f278a
parent 5551 327690766109
permissions -rw-r--r--
6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows Reviewed-by: alexp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4379
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
     1
/*
6659
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
     2
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4379
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
     4
 *
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
     8
 *
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    13
 * accompanied this code).
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    14
 *
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    18
 *
5551
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 4379
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 4379
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 4379
diff changeset
    21
 * questions.
4379
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    22
 */
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    23
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    24
/* @test
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    25
   @bug 6888156
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    26
   @summary Tests table column of class Icon.class with Synth LAF
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    27
   @author Peter Zhelezniakov
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    28
   @run main Test6888156
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    29
*/
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    30
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    31
import java.awt.Component;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    32
import java.awt.Graphics;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    33
import java.awt.image.BufferedImage;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    34
import javax.swing.*;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    35
import javax.swing.table.AbstractTableModel;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    36
import javax.swing.table.TableModel;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    37
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    38
public class Test6888156 {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    39
    private JTable table;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    40
    private Icon ICON = new Icon() {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    41
        @Override public int getIconWidth() {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    42
            return 24;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    43
        }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    44
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    45
        @Override public int getIconHeight() {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    46
            return 24;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    47
        }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    48
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    49
        @Override public void paintIcon(Component c, Graphics g, int w, int h) {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    50
        }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    51
    };
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    52
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    53
    public Test6888156() {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    54
        TableModel model = new AbstractTableModel() {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    55
            @Override public int getRowCount() {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    56
                return 3;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    57
            }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    58
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    59
            @Override public int getColumnCount() {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    60
                return 2;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    61
            }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    62
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    63
            @Override public Object getValueAt(int rowIndex, int columnIndex) {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    64
                return (columnIndex == 1 ? ICON : 4);
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    65
            }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    66
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    67
            @Override public Class<?> getColumnClass(int columnIndex) {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    68
                return (columnIndex == 1 ? Icon.class : int.class);
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    69
            }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    70
        };
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    71
        table = new JTable(model);
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    72
    }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    73
6659
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
    74
    public void test(final String laf) throws Exception {
4379
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    75
        SwingUtilities.invokeAndWait(new Runnable() {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    76
            @Override public void run() {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    77
                try {
6659
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
    78
                    System.out.println(laf);
4379
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    79
                    UIManager.setLookAndFeel(laf);
6659
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
    80
                } catch (Exception e) {
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
    81
                    System.err.println(laf + " is unsupported; continuing");
4379
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    82
                    return;
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    83
                }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    84
                SwingUtilities.updateComponentTreeUI(table);
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    85
                table.setSize(100, 100);
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    86
                table.paint(
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    87
                        new BufferedImage(100, 100, BufferedImage.OPAQUE).
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    88
                            getGraphics());
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    89
            }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    90
        });
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    91
    }
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    92
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    93
    public static void main(String[] args) throws Exception {
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
    94
        Test6888156 t = new Test6888156();
6659
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
    95
        t.test("javax.swing.plaf.nimbus.NimbusLookAndFeel");
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
    96
        t.test("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
    97
        for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
    98
            t.test(laf.getClassName());
8add9a1f278a 6986450: javax/swing/JTable/Test6888156.java test is failing against jdk7 just on windows
malenkov
parents: 5551
diff changeset
    99
        }
4379
ce28939f55fc 6888156: With GTK Look and Feel Icons cannot be rendered in Jtable Cells
peterz
parents:
diff changeset
   100
    }
5551
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 4379
diff changeset
   101
}