jdk/test/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI/7089914/bug7089914.java
author katleman
Thu, 20 Dec 2012 16:24:50 -0800
changeset 14856 92a1bcf46888
parent 11975 d3620e28371c
child 32286 5ffa8d8b4a2d
permissions -rw-r--r--
8004982: JDK8 source with GPL header errors Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11975
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
     1
/*
14856
92a1bcf46888 8004982: JDK8 source with GPL header errors
katleman
parents: 11975
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
11975
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
     4
 *
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
     8
 *
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    13
 * accompanied this code).
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    14
 *
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    18
 *
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    21
 * questions.
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    22
 */
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    23
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    24
/*
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    25
 * Portions Copyright (c) 2012 IBM Corporation
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    26
 */
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    27
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    28
/* @test
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    29
 * @bug 7089914
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    30
 * @summary Focus on image icons are not visible in javaws cache with high contrast mode
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    31
 * @author Sean Chou
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    32
 */
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    33
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    34
import javax.swing.*;
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    35
import java.lang.reflect.Field;
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    36
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    37
public class bug7089914 {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    38
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    39
    public static void main(String[] args) throws Exception {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    40
        try {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    41
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    42
        } catch (Exception e) {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    43
            System.out.println("Not WindowsLookAndFeel, test skipped");
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    44
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    45
            return;
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    46
        }
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    47
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    48
        SwingUtilities.invokeAndWait(new Runnable() {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    49
            @Override
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    50
            public void run() {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    51
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    52
                JRadioButton rb = new JRadioButton();
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    53
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    54
                if (!"com.sun.java.swing.plaf.windows.WindowsRadioButtonUI".equals(rb.getUI().getClass().getName())) {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    55
                    throw new RuntimeException("Unexpected UI class of JRadioButton");
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    56
                }
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    57
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    58
                try {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    59
                    Field initializedField = rb.getUI().getClass().getDeclaredField("initialized");
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    60
                    initializedField.setAccessible(true);
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    61
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    62
                    if (!initializedField.getBoolean(rb.getUI())) {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    63
                        throw new RuntimeException("initialized is false");
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    64
                    }
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    65
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    66
                    rb.getUI().uninstallUI(rb);
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    67
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    68
                    if (initializedField.getBoolean(rb.getUI())) {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    69
                        throw new RuntimeException("initialized is true");
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    70
                    }
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    71
                } catch (NoSuchFieldException | IllegalAccessException e) {
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    72
                    throw new RuntimeException(e);
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    73
                }
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    74
            }
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    75
        });
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    76
    }
d3620e28371c 7089914: Focus on image icons are not visible in javaws cache with high contrast mode
rupashka
parents:
diff changeset
    77
}