3099N/A/*
3099N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3099N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3099N/A *
3099N/A * This code is free software; you can redistribute it and/or modify it
3099N/A * under the terms of the GNU General Public License version 2 only, as
3099N/A * published by the Free Software Foundation.
3099N/A *
3099N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3099N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3099N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3099N/A * version 2 for more details (a copy is included in the LICENSE file that
3099N/A * accompanied this code).
3099N/A *
3099N/A * You should have received a copy of the GNU General Public License version
3099N/A * 2 along with this work; if not, write to the Free Software Foundation,
3099N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3099N/A *
3099N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3099N/A * or visit www.oracle.com if you need additional information or have any
3099N/A * questions.
3099N/A */
3099N/A
3099N/A/* @test
3099N/A @bug 4150029
3099N/A @summary BackSpace keyboard button does not lead to parent directory
3099N/A @author Oleg Mokhovikov
3099N/A @run applet/manual=done bug4150029.html
3099N/A*/
3099N/A
3099N/Aimport javax.swing.*;
3099N/Aimport java.io.File;
3099N/Aimport java.io.IOException;
3099N/A
3099N/Apublic class bug4150029 extends JApplet {
3099N/A private boolean res;
3099N/A
3099N/A public void init() {
3099N/A String tmpDir = System.getProperty("java.io.tmpdir");
3099N/A
3099N/A if (tmpDir.length() == 0) {//'java.io.tmpdir' isn't guaranteed to be defined
3099N/A tmpDir = System.getProperty("user.home");
3099N/A }
3099N/A
3099N/A System.out.println("Temp directory: " + tmpDir);
3099N/A
3099N/A File testDir = new File(tmpDir, "testDir");
3099N/A
3099N/A testDir.mkdir();
3099N/A
3099N/A File subDir = new File(testDir, "subDir");
3099N/A
3099N/A subDir.mkdir();
3099N/A
3099N/A System.out.println("Created directory: " + testDir);
3099N/A System.out.println("Created sub-directory: " + subDir);
3099N/A
3099N/A JFileChooser fileChooser = new JFileChooser(testDir);
3099N/A
3099N/A fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
3099N/A
3099N/A try {
3099N/A res = fileChooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION ||
3099N/A testDir.getCanonicalPath().equals(fileChooser.getSelectedFile().getCanonicalPath());
3099N/A } catch (IOException e) {
3099N/A res = false;
3099N/A
3099N/A e.printStackTrace();
3099N/A }
3099N/A
3099N/A try {
3099N/A subDir.delete();
3099N/A testDir.delete();
3099N/A } catch (SecurityException e) {
3099N/A e.printStackTrace();
3099N/A }
3099N/A }
3099N/A
3099N/A public void destroy() {
3099N/A if (!res) {
3099N/A throw new RuntimeException("BackSpace keyboard button does not lead to parent directory");
3099N/A }
3099N/A }
3099N/A}