< prev index next >

java/awt/FileDialog/FileDialogOpenDirTest/FileDialogOpenDirTest.java

Print this page


   1 /*























   2  test
   3  @bug 4974135
   4  @summary FileDialog should open current directory by default.
   5  @author tav@sparc.spb.su area=awt.filedialog
   6  @run applet/manual=yesno FileDialogOpenDirTest.html
   7 */
   8 
   9 import java.awt.*;
  10 import java.awt.event.*;
  11 import java.applet.*;
  12 
  13 public class FileDialogOpenDirTest extends Applet {
  14 
  15     public static void main(String[] args) {
  16         Applet a = new FileDialogOpenDirTest();
  17         a.init();
  18         a.start();
  19     }
  20 
  21     public void init()
  22     {
  23         System.setProperty("sun.awt.disableGtkFileDialogs","true");
  24         //Create instructions for the user here, as well as set up
  25         // the environment -- set the layout manager, add buttons,
  26         // etc.
  27         this.setLayout (new BorderLayout ());
  28 
  29         String curdir = System.getProperty("user.dir");
  30 
  31         String[] instructions1 =
  32         {
  33             "After test started you will see 'Test Frame' with a button inside.",
  34             "Click the button to open FileDialog.",
  35             "Verify that the directory opened is current directory, that is:",
  36             curdir,
  37             "If so press PASSED, otherwise FAILED."
  38         };
  39 
  40         String[] instructions2 =
  41         {
  42             "Not for Windows. Press PASSED."
  43         };
  44 
  45         Sysout.createDialogWithInstructions(Toolkit.getDefaultToolkit().getClass().getName().
  46                                             equals("sun.awt.windows.WToolkit") ?
  47                                             instructions2 : instructions1);
  48     }
  49 
  50     public void start() {
  51         Frame frame = new Frame("Test Frame");
  52         Button open = new Button("Open File Dialog");
  53 
  54         open.addActionListener(new ActionListener() {
  55                 public void actionPerformed(ActionEvent e) {
  56                     new FileDialog(new Frame()).show();
  57                 }
  58             });
  59 
  60         frame.setLayout(new FlowLayout());
  61         frame.add(open);
  62 
  63         int x = 0;
  64         int y = 0;
  65         Component dlg = null;
  66 
  67         if ((dlg = Sysout.getDialog()) != null) {


   1 /*
   2  * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  test
  26  @bug 4974135
  27  @summary FileDialog should open current directory by default.
  28  @author tav@sparc.spb.su area=awt.filedialog
  29  @run applet/manual=yesno FileDialogOpenDirTest.html
  30 */
  31 
  32 import java.awt.*;
  33 import java.awt.event.*;
  34 import java.applet.*;
  35 
  36 public class FileDialogOpenDirTest extends Applet {
  37 
  38     public static void main(String[] args) {
  39         Applet a = new FileDialogOpenDirTest();
  40         a.init();
  41         a.start();
  42     }
  43 
  44     public void init()
  45     {
  46         System.setProperty("sun.awt.disableGtkFileDialogs","true");
  47         //Create instructions for the user here, as well as set up
  48         // the environment -- set the layout manager, add buttons,
  49         // etc.
  50         this.setLayout (new BorderLayout ());
  51 
  52         String curdir = System.getProperty("user.dir");
  53 
  54         String[] instructions1 =
  55         {
  56             "After test started you will see 'Test Frame' with a button inside.",
  57             "Click the button to open FileDialog.",
  58             "Verify that the directory opened is current directory, that is:",
  59             curdir,
  60             "If so press PASSED, otherwise FAILED."
  61         };
  62 
  63         String[] instructions2 =
  64         {
  65             "The test is not applicable for current platform. Press PASSED."
  66         };
  67 
  68         Sysout.createDialogWithInstructions(Toolkit.getDefaultToolkit().getClass().getName().
  69                                             equals("sun.awt.X11.XToolkit") ?
  70                                             instructions1 : instructions2);
  71     }
  72 
  73     public void start() {
  74         Frame frame = new Frame("Test Frame");
  75         Button open = new Button("Open File Dialog");
  76 
  77         open.addActionListener(new ActionListener() {
  78                 public void actionPerformed(ActionEvent e) {
  79                     new FileDialog(new Frame()).show();
  80                 }
  81             });
  82 
  83         frame.setLayout(new FlowLayout());
  84         frame.add(open);
  85 
  86         int x = 0;
  87         int y = 0;
  88         Component dlg = null;
  89 
  90         if ((dlg = Sysout.getDialog()) != null) {


< prev index next >