jdk/test/javax/swing/JFileChooser/4847375/bug4847375.java
author duke
Wed, 05 Jul 2017 17:52:05 +0200
changeset 10620 9df40a1578ef
parent 7788 e00adc6a09e7
child 31448 1066345d2a8a
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7788
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
     1
/*
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
     4
 *
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
     8
 *
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    13
 * accompanied this code).
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    14
 *
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    18
 *
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    21
 * questions.
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    22
 */
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    23
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    24
/*
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    25
 * @test
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    26
 * @bug 4847375
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    27
 * @summary JFileChooser Create New Folder button is disabled incorrectly
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    28
 * @author Pavel Porvatov
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    29
 */
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    30
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    31
import sun.awt.OSInfo;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    32
import sun.awt.shell.ShellFolder;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    33
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    34
import javax.swing.*;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    35
import java.awt.*;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    36
import java.lang.reflect.Method;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    37
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    38
public class bug4847375 {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    39
    private final String newFolderToolTipText;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    40
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    41
    private final String lookAndFeel;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    42
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    43
    public static void main(String[] args) throws Exception {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    44
        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    45
            System.out.println("The test is suitable only for Windows OS. Skipped.");
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    46
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    47
            return;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    48
        }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    49
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    50
        SwingUtilities.invokeAndWait(new Runnable() {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    51
            public void run() {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    52
                new bug4847375("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    53
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    54
                new bug4847375("javax.swing.plaf.metal.MetalLookAndFeel");
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    55
            }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    56
        });
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    57
    }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    58
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    59
    private static Object[][] DIRECTORIES = new Object[][]{
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    60
            {"getDesktop", Boolean.TRUE},
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    61
            {"getDrives", Boolean.FALSE}, // My computer
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    62
            {"getRecent", Boolean.TRUE},
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    63
            {"getNetwork", Boolean.FALSE},
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    64
            {"getPersonal", Boolean.TRUE},
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    65
    };
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    66
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    67
    private bug4847375(String lookAndFeel) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    68
        this.lookAndFeel = lookAndFeel;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    69
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    70
        try {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    71
            UIManager.setLookAndFeel(lookAndFeel);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    72
        } catch (Exception e) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    73
            fail("Cannot set LookAndFeel", e);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    74
        }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    75
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    76
        JFileChooser fileChooser = new JFileChooser();
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    77
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    78
        // Find button NewFolder
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    79
        newFolderToolTipText = UIManager.getString("FileChooser.newFolderToolTipText", fileChooser.getLocale());
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    80
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    81
        if (newFolderToolTipText == null || newFolderToolTipText.length() == 0) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    82
            fail("Cannot find NewFolderButton in FileChooser (tooltip doesn't exist)");
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    83
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    84
            return;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    85
        }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    86
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    87
        JButton newFolderButton = findNewFolderButton(fileChooser);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    88
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    89
        if (newFolderButton == null) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    90
            fail("Cannot find NewFolderButton in FileChooser");
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    91
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    92
            return;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    93
        }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    94
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    95
        for (Object[] objects : DIRECTORIES) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    96
            String getterName = (String) objects[0];
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    97
            Boolean enabledNewFolder = (Boolean) objects[1];
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    98
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
    99
            fileChooser.setCurrentDirectory(getWin32Folder(getterName));
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   100
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   101
            if (newFolderButton.isEnabled() != enabledNewFolder) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   102
                fail("Enabled state of NewFolderButton should be " + enabledNewFolder +
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   103
                        " for Win32ShellFolderManager2." + getterName + "()");
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   104
            }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   105
        }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   106
    }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   107
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   108
    private JButton findNewFolderButton(Container container) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   109
        JButton result = null;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   110
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   111
        for (int i = 0; i < container.getComponentCount(); i++) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   112
            Component c = container.getComponent(i);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   113
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   114
            if (c instanceof JButton && newFolderToolTipText.equals(((JButton) c).getToolTipText())) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   115
                if (result != null) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   116
                    fail("Two or more NewFolderButton found in FileChooser");
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   117
                }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   118
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   119
                result = (JButton) c;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   120
            }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   121
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   122
            if (c instanceof Container) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   123
                JButton button = findNewFolderButton((Container) c);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   124
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   125
                if (result == null) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   126
                    result = button;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   127
                } else {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   128
                    if (button != null) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   129
                        fail("Two or more NewFolderButton found in FileChooser");
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   130
                    }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   131
                }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   132
            }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   133
        }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   134
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   135
        return result;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   136
    }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   137
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   138
    private ShellFolder getWin32Folder(String getterName) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   139
        try {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   140
            Class win32ShellFolderManager2 = Class.forName("sun.awt.shell.Win32ShellFolderManager2");
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   141
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   142
            Method method = win32ShellFolderManager2.getDeclaredMethod(getterName);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   143
            method.setAccessible(true);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   144
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   145
            return (ShellFolder) method.invoke(null);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   146
        } catch (Exception e) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   147
            fail("Cannot call '" + getterName + "' in the Win32ShellFolderManager2 class", e);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   148
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   149
            return null;
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   150
        }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   151
    }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   152
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   153
    private void fail(String s) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   154
        throw new RuntimeException("Test failed: " + s);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   155
    }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   156
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   157
    private void fail(String s, Throwable e) {
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   158
        throw new RuntimeException("Test failed for LookAndFeel " + lookAndFeel + ": " + s, e);
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   159
    }
e00adc6a09e7 6959584: closed/javax/swing/JFileChooser/4847375/bug4847375.java : compilation failed
rupashka
parents:
diff changeset
   160
}