Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4410113

Win98, WinNt, JFileChooser only displays DeskTop directory and its contents

    XMLWordPrintable

Details

    Description



      Name: jbT81659 Date: 01/31/2001

      OS: Win98/NT
      JDK: JDK1.4.0-Beta49

      JFileChooser points to desktop only. It does not show any other directories or disks
      including CDROM and Floppy under Windows 98 and Windows NT.
      To reproduce bug:
      1- Compile and run the following code under Win98 and WinNT(jFileChooser.java)
      2- In the "Look In" field, note that "Desktop" is displayed
      3- Open the "ook In" ComboPanel
      4- Note that No other directories are available
      5- Repeat under Windows NT

      --------Code-------------------
      /*
      Copyright (c) Sun Microsystems 1998

      $Header: /home/sun/src/JDK1.2/jFileChooser.java,v 1.8 1999/11/28 11:34:25 isam Exp $

      */

      import java.awt.*;
      import java.awt.event.*;
      import java.io.*;
      import javax.swing.*;

      public class jFileChooser extends JApplet
      {
              public void init()
              {
                      jFileChooser1 sfc = new jFileChooser1();
                      sfc.setVisible(true);
              }

              public static void main(String[] argv)
              {
                      jFileChooser1 sfc = new jFileChooser1();
                      sfc.setVisible(true);
              }

      }

      class jFileChooser1 extends JFrame
      {
              JFrame parent;
              public jFileChooser1()
              {
                  super("\u0645\u062b\u0627\u0644");
                  setSize(350, 200);
                  parent = this;
                  Container c = getContentPane();
                  c.setLayout(new GridLayout(10,1));

                  JButton openButton = new JButton("\u05d8\u05e2\u05df");
                  JButton saveButton = new JButton("\u05d0\u05d7\u05e1\u05df");
                  JButton dirButton = new JButton("\u0625\u062e\u062a\u0627\u0631");
                  final JLabel statusbar =
                  new JLabel("\u0645\u062b\u0627\u0644\u0020\u05d3\u05d2\u05de\u05d4 JFileChooser");
                  statusbar.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 18));

                  openButton.addActionListener(new ActionListener()

                  {
                  public void actionPerformed(ActionEvent ae)
                  {
                      JFileChooser chooser = new JFileChooser();
                      int option = chooser.showOpenDialog(parent);
                      if (option == JFileChooser.APPROVE_OPTION)
                      {
                              statusbar.setText("You chose " +
                              ((chooser.getSelectedFile()!=null)?
                                    chooser.getSelectedFile().getName():
                                    "nothing"));
                      }
              else
              {
              // statusbar.setText("You canceled.");
              }
            }
          });

          saveButton.addActionListener(new ActionListener()
          {
          public void actionPerformed(ActionEvent ae)
          {
              JFileChooser chooser = new JFileChooser();
              int option = chooser.showSaveDialog(parent);
              if (option == JFileChooser.APPROVE_OPTION)
              {
                      statusbar.setText("You saved " +
                                  ((chooser.getSelectedFile()!=null)?
                                    chooser.getSelectedFile().getName():
                                    "nothing"));
              }
              else
              {
                      statusbar.setText("You canceled.");
              }
            }
          });

          dirButton.addActionListener(new ActionListener()
          {
              public void actionPerformed(ActionEvent ae)
              {
                      JFileChooser chooser = new JFileChooser();
                      chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                      int option = chooser.showOpenDialog(parent);
                      if (option == JFileChooser.APPROVE_OPTION)
                      {
                              statusbar.setText("You opened " +
                                  ((chooser.getSelectedFile()!=null)?
                                    chooser.getSelectedFile().getName():
                                    "nothing"));
                      }
                      else
                      {
                              statusbar.setText("You canceled.");
                      }
              }
          });

          openButton.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 18));
          saveButton.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 18));
          dirButton.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 18));

          c.add(openButton);
          c.add(saveButton);
          c.add(dirButton);
          //c.add(statusbar);
        }
      }
      ---------------


      WorkAround:
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              leifs Leif Samuelsson (Inactive)
              jbenavrasunw Jonathan Benavraham (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: