🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7576

JFileChooser questions

#7576
From: Mark Sayer
Date: Fri, 08 Jun 2001 22:39
89 lines
3425 bytes
Hello,


I am using the following code to save a file. I basicaly slightly
modified Borland's tutorial. Now here is the problem.

Initially i display "untitled.xml" in the field. As I traverse
directories by double clicking on the dir name, this field changes to
the name of the directory which offcourse I don't want to happen. 

I am using JBuilder Foundation and it just occured to me that it also
uses JFileChooser, but it doesn't have the problem that I have with my
code  <sigh>

So, here is the first question, how does Borland do it (right) ?


Following is the code:

******************************************

      boolean saveAs(){


        if (currentUserDir ==null)
	  jFileChooser1.setCurrentDirectory(new
File(System.getProperty("user.dir")));
        else
	  jFileChooser1.setCurrentDirectory(currentUserDir);

        jFileChooser1.setSelectedFile(new File("untitled.xml"));
        int result = jFileChooser1.showSaveDialog(this);

        if (result == JFileChooser.APPROVE_OPTION) {
		File f = jFileChooser1.getSelectedFile();
		if (f == null)
			return false;
		if (f.getName().equals(""))
			return false;

       currFileName =f.getPath();
       currentUserDir = new File(f.getParent());

       File checkFile = new File(currFileName);
       if (checkFile.exists() == true){
       int value = JOptionPane.showConfirmDialog(this,"OKAY to
Overwrite?",
                      "Confirm",  JOptionPane.YES_NO_OPTION );

        switch (value){
              case JOptionPane.YES_OPTION:
                                  {
                                      return save();
                                      }

              case JOptionPane.NO_OPTION:
              default:{
                          return false;
                       }
                  }
              }

          else
              return save();
        }

            else
                return false;
    }

******************************************


Here is my next question:

In filechooser I use the make new folder button and it makes a new
folder with name "new folder". However, I like it to force it to be in
the view and be in (name) editable mode..that is when I make a new
folder, it should focus on the "new folder" name field and editable.
Right now, if I have 20+ files (for example) then after making the new
folder, the darn thing rescans the dirs and displays last "n" files, so
I have to now scroll up to find and edit the name for the "new folder".

How do I achieve this?


TIA

Mark
Technical Details
Message-ID: <3B215424.49AD4D62@yahoo.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,4bec74cf577e6090,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-08 15:44:39 PST
Message-ID: <3B215424.49AD4D62@yahoo.com>
Date: Fri, 08 Jun 2001 17:39:32 -0500
From: Mark Sayer <marksayer_99@yahoo.com>
Organization: Home 
X-Mailer: Mozilla 4.76 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: JFileChooser questions
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 135.2.130.210
X-Trace: dnews 992039840 135.2.130.210 (8 Jun 2001 15:37:20 -0700)
Lines: 89
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews