4630N/A/*
4630N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4630N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4630N/A *
4630N/A * This code is free software; you can redistribute it and/or modify it
4630N/A * under the terms of the GNU General Public License version 2 only, as
4630N/A * published by the Free Software Foundation.
4630N/A *
4630N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4630N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4630N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4630N/A * version 2 for more details (a copy is included in the LICENSE file that
4630N/A * accompanied this code).
4630N/A *
4630N/A * You should have received a copy of the GNU General Public License version
4630N/A * 2 along with this work; if not, write to the Free Software Foundation,
4630N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4630N/A *
4630N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4630N/A * or visit www.oracle.com if you need additional information or have any
4630N/A * questions.
4630N/A */
4630N/A
4630N/A/* @test
4630N/A * @bug 7082443
4630N/A * @summary JComboBox not backward compatible (with Java 6)
4630N/A * @author Pavel Porvatov
4630N/A */
4630N/A
4630N/Aimport javax.swing.*;
4630N/Aimport java.awt.*;
4630N/A
4630N/Apublic class bug7082443 {
4630N/A public static final String GTK_LAF_CLASS = "GTKLookAndFeel";
4630N/A
4630N/A public static void main(String[] args) throws Exception {
4630N/A for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
4630N/A if (lookAndFeelInfo.getClassName().contains(GTK_LAF_CLASS)) {
4630N/A UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
4630N/A
4630N/A SwingUtilities.invokeAndWait(new Runnable() {
4630N/A @Override
4630N/A public void run() {
4630N/A TestComboBox testComboBox = new TestComboBox();
4630N/A
4630N/A if (testComboBox.isOldRendererOpaque()) {
4630N/A System.out.println("Passed for " + GTK_LAF_CLASS);
4630N/A } else {
4630N/A throw new RuntimeException("Failed for " + GTK_LAF_CLASS);
4630N/A }
4630N/A }
4630N/A });
4630N/A
4630N/A return;
4630N/A }
4630N/A }
4630N/A
4630N/A System.out.println(GTK_LAF_CLASS + " is not found. The test skipped");
4630N/A }
4630N/A
4630N/A private static class TestComboBox extends JComboBox {
4630N/A private final ListCellRenderer renderer = new ListCellRenderer() {
4630N/A @Override
4630N/A public Component getListCellRendererComponent(JList list, Object value, int index,
4630N/A boolean isSelected, boolean cellHasFocus) {
4630N/A return TestComboBox.super.getRenderer().getListCellRendererComponent(list, value, index,
4630N/A isSelected, cellHasFocus);
4630N/A }
4630N/A };
4630N/A
4630N/A @Override
4630N/A public ListCellRenderer getRenderer() {
4630N/A return renderer;
4630N/A }
4630N/A
4630N/A public boolean isOldRendererOpaque() {
4630N/A return ((JLabel) super.getRenderer()).isOpaque();
4630N/A }
4630N/A }
4630N/A}
4630N/A