How can I create a directory chooser?

hi there
is there any way to create a directory chooser? because it is the directory that I am more interested in, but with JFileChooser, I must select a file to get a directory. help please, and thank you.

Just a followup regarding directory choosers.
I previously attempted to use the JFileChooser.DIRECTORIES_ONLY selection to make a directory chooser, but found that this didn't allow the user to descend into the wanted directory, then select it.
The following code shows my attempt to resolve this. BTW, this works because the assumption has been made that when a directory is descended into, its name will appear in the file name field.
JFileChooser browser = new JFileChooser(System.getProperty("user.dir"));
               browser.removeChoosableFileFilter(browser.getAcceptAllFileFilter());
               browser.addChoosableFileFilter(new DirectoriesOnlyFilter());
               //This method will set the dialog type to custom via setDialogType(CUSTOM_DIALOG);
               if (browser.showDialog(this, "Select") != JFileChooser.APPROVE_OPTION)
                    return;
               File location = browser.getSelectedFile();
               if (!location.exists())
                    String dirName = location.getName();
                    //Find the requested directory by looking at the parent directory
                    location = location.getParentFile();
                    if (location.exists() && location.getName().equals(dirName))
                         //User has descended into the wanted directory -
                    else
                         //Cannot resolve the requested directory
               else if (location.isDirectory())
                    //The user has clicked, without descending, onto a directory in the chooser
                    //This is the directory that the user wants
               else
                    //Oops - File found.  This should only happen in one of two cases:
                    //1) If there is a file with the same name as the directory it is in
                    //2) If the user has typed in a file name into the field
class DirectoriesOnlyFilter extends javax.swing.filechooser.FileFilter
     public DirectoriesOnlyFilter()
     public boolean accept(File file)
          return file.isDirectory();
     public String getDescription()
          return "Directories";
}Hope this helps.
Rob

Similar Messages

  • How can I create a directory on my server using FTP in applescript?

    Hi
    I have created a script which successfully uploads files to my server using FTP and a curl command.
    The one thing I haven't worked out how to do is how to create a directory on my server using applescript. At the moment I have to manually create the correct directory for the script to work, but would like to be able to automate everything.
    Would this be possible?
    Thanks
    Nick

    Thanks Bernard.
    I have tried that and still get the error message:
    "curl: Can't open '--ftp-create-dirs'!
    curl: try 'curl --help' or 'curl --manual' for more information
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
    curl: (9) Server denied you to change to the given directory"
    The other relevant parts of the script are:
    set ftp_url to "ftp.****.org.uk/artists/" & artistName2 & "/assets/"
    set ftp_username to "*****@*****.org.uk"
    set ftp_password to "****"
    set ftp_entire to ftp_username & ":" & ftp_password & " ftp://" & ftp_url
    set outPath to outputFolder & fileCounter & ".jpg"
    and then...
    do shell script ("curl -T --ftp-create-dirs " & outPath & " -u " & ftp_entire)
    Like I said, all works fine when the directories are already in place. I have permissions for the artists folder set to "777", i.e. writable. Because the script is trying to create two directories at once, i.e. "artistName2" and then "assets" under it, I wondered if this was significant, but then I tried with just one new directory, and still got the error.

  • How can i create a gradient chooser within the plugin window

    Hi
    i'd like to create a gradient chooser similar to the one used in Photoshop but inside the plugin window.
    How can i do that ?
    And i need a way that is compatible Mac/windows if possible
    thanks a lot!
    Jeff

    Hi Chris
    thank you for your answer.
    finally i got WxWidgets working within Photoshop thanks to Dimitri from wx-users and i also found an all-done gradient editor! so all is good thanks
    Jeff

  • How can i create a dir chooser with jdk 1.1.4?

    Hi,
    I am wrote an applet that must be compatible with jdk 1.1.4, it is responsible for downloading files from a server to the clients computer.
    I wanted some kind of directory chooser that only lists the directories, but java.awt.FileDialog didn't give me what I wanted,how can i do?
    anyone can give me help?

    thanks a lot for your help.i used a FilenameFilter and defined accept() method. in mac os 8 FileDialog now can only display directory.but another problem is FileDialog need a file to choose, otherwise the thing you can do is canceling this FileDialog.anybody help me?

  • How can i create work directory for Tomcat4 which is installed on Mandrake

    Hello Everybody,
    I installed Tomcat4 with the help of JPackage on Madrake Linux. It is working fine. But Unfortunatly my work folder in tomcat4 is deleted. I restarted my Tomcat, But the work folder not created. my application is not working. I need help from u people. Is there any other options to create work folder. I installed the tomcat4 from jpackage.
    Thanks in advance, Naveen Kumar Madugula

    4) Advanced Configuration - Multiple Tomcat 4 Instances
    In many circumstances, it is desirable to have a single copy of a Tomcat 4
    binary distribution shared among multiple users on the same server. To make
    this possible, you must configure a CATALINA_BASE environment variable (in
    addition to CATALINA_HOME as described above) that points to a directory
    that is unique to your instance.
    When you do this, Tomcat 4 will calculate all relative references for files in
    the following directories based on the value for CATALINA_BASE instead of
    CATALINA_HOME:
    * conf - Server configuration files (including server.xml)
    * logs - Log and output files
    * shared - For classes and resources that must be shared across all web
    applications
    * webapps - Automatically loaded web applications
    * work - Temporary working directories for web applications
    * temp - Directory used by the JVM for temporary files (java.io.tmpdir)
    If you do not set CATALINA_BASE to an explicit value, it will be initialized
    to the same value as is set for CATALINA_HOME (which means that the same
    directory is used for all relative path resolutions).
    more -> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/RUNNING.txt

  • How can I create a array with all files from a directory

    How can I create a array of files or varchar with all files from a directory?

    I thought the example could be improved upon. I've posted a solution on my blog that doesn't require writing the directory list to a table. It simply returns it as a nested table of files as a SQL datatype. You can find it here:
    http://maclochlainn.wordpress.com/2008/06/05/how-you-can-read-an-external-directory-list-from-sql/

  • How can I create an iPhoto Library from photos on an external drive?

    Here's my issue:
    I have a MacBook Pro running OS X Mavericks, and I am just about out of hard drive space.
    I also have about 20 GB worth of photos on an external drive. The photos are not organized at all, just got dumped into a folder there during a hasty backup a couple years ago.
    I'd like to use iPhoto to get these photos organized, but don't have the space to import them into the library on my laptop.
    How can I create and manage an iPhoto library with these photos while keeping them on the external drive? They are on a terabyte drive, so I have a feeling I'd like to make that my main library moving forward.

    Check that the drive's formatted as Mac OS Extended, drag the iPhoto library to it, launch iPhoto with the Option key held down, and choose that library.
    (114618)

  • How can I create an Excel file?

    Hi,
    How can I create an Excel file using Forms 6i.
    What I'm doing is to create a file using TEXT_IO package an name it .XLS. If a read it double-clicking over the file, it opens Ok but If I open directly from Excel it opens the Convert dialog.
    I need to create an excel file as it was made from within Excel.
    Thank in advance,
    Benjamin

    When you are talking about subfiles, are you talking like Package contents of an application?
    Terminal application in Applications -> Utilities can give a command line grasp of all your files using the du command.
    Type
    man du
    when entering the terminal, followed by the enter key.
    Note, by default the terminal opens at the Home folder.   To navigate outside the Home folder enter "/Volumes/name of mounted drive/folder/subfolder" as your path.  If there are spaces in the name, putting quotes around the whole path can help.    If you end your du command with a > name.txt a text file with the name name.txt will be plugged into your Home directory.  That you can open with Excel and parse by /es thus giving you everything in Excel.

  • How can I create a new entry without using LOV for foreign keys.

    Referring to TUHRA sample application based on HR database schema. JDeveloper 10.1.3.0.4
    How can I create a new employee without using LOV for the foreign key "job_id".
    On the first page I would like to choose the job_title from adf read-only table.
    After clicking on the "create new employee button" a creation form appears in which the job_id field is set with previous selection.
    Regards M.Winkler
    Edited by: user3541283 on 06.10.2008 03:44
    Edited by: user3541283 on 06.10.2008 03:50

    Hi,
    usually the foreign key is only set if the VO you select is dependent from a master. If e.g. you have DepartmentsVO1 that has an EmployeeVO3 as its nested VO, then creating a new instance of employees automatically add the foreign key. If you add EmployeesVO1, which is not dependent to DepartmensVO1, then the foreign key is not set. So if this is the case in THURA (keep in mind that this is not an Oracle demo but a sample used in a book about ADF) then all you need is to take the independent VO when building the new employee form.
    Frank

  • How can I create a new DAD?

    HI,
    I'm just starting on oracle 10g XE and i want to know how can i create a dad to access a procedure I create in a new user.
    Let me explain better...
    After the instalation the only user created was the user HR.
    Now I have created the user RICARDO and I want to access the procedure TEST.
    like this: http://127.0.0.1:8080/pls/RICARDO/TEST
    Is that possible or i have to install the iAS?

    Well, you could install an Apache http server as a proxy to XE and define a virtual directory mapping there (pointing to c:\temp).
    See these threads for details:
    Re: Existing http server
    HTTPS with Oracle XE ?
    Re: How to get X-Forwarded-For value?
    Or you could use store the files using WebDav in the database and reference it there.
    Oracle Application Express included in XE does that. They have moved the files of a standalone version from the filesystem to the database:
    http://daust.blogspot.com/2006/03/where-are-images-of-application.html
    ~Dietmar.

  • How can I create a new E-mail address for the Marketing Manager

    Hullo,
    how can I create a new E-mail address for the Marketing Manager (i.e. marketing professional role in SAP CRM) please.
    That when you go and create a new E-mail campaign you need to choose an E-mail form in addition to the E-mail address of the Marketing Manager.
    Kind Regards.

    Hi Alhussien
    Add it to his Position in the Organisational Model. Transaction PPOMA_CRM.
    Under there address section is an option to populate the email address.
    Regards
    Arden

  • How can i create a new and tableless database using database configuration

    How can i create a new and tableless database using database configuration

    How can i create a new and tableless database using database configuration
    Just don't install the sample schemas. See the installation guide
    http://docs.oracle.com/cd/E11882_01/server.112/e10831/installation.htm
    Using the Database Configuration Assistant
    When you install Oracle Database with the Oracle Universal Installer, the sample schemas are installed by default if you select the Basic Installation option. Selecting the sample schemas option installs all five schemas (HR, OE, PM, IX, and SH) in the database. If you choose not to install the sample schemas at that time, you can add them later by following the instructions in section "Manually Installing Sample Schemas".
    Choose a custom install and don't install the sample schemas.
    All other schems/tables installed are REQUIRED by Oracle

  • How can I create a new page in pages, without creating a new section?

    how can I create a new page in pages, without creating a new section?

    Good morning graywright,
    It sounds as if what you are wanting to do in the Pages application is to insert a Page Break. Follow the steps in this article -
    Pages '09: Inserting a Page Break
    In a word processing document, click where you want the break to occur, and then choose Insert > Page Break. 
    To remove a page break, click at the beginning of the line that follows the break and press the Delete key.
    In a page layout document, to insert a new page in your document, click Pages in the toolbar and choose from the template page options available.
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • How can I create a new folder in Word for Mac ?

    How can I create a new folder in Word for Mac?

    You don't do this in Word. You do it in the OS X Finder.
    All you need do in Word is open the file, then select Save As from Word's File menu. Change the destination to your new folder then click on the Save button.
    The Finder method is much faster if you have a number of files you want to move. Just remember that to open those moved files in Word, you will have to change the directory from which you will open those files.

  • How can I create a loopback activity

    Hello All.
    How can I create a loopback process in BPEL? For example: I have a flow that has a human task that submits a proposal. After
    this, Theres is another human task that will review this proposal with Approve or Reject options. If it is approved, then the flow goes on. If it is rejected, then the flow has to go back to the proposal subimission process. You can see an image (the first image in the URL) that ilustrates this flow here: http://onbpms.com/2007/02/08/looping-backward/. The rest of the page is not important. Just look at the image to understand my problem. How can implement such loop in BPEL?
    I´m using JDeveloper Studio Edition 10.1.3.2.0.4066 and SOA Suite 10.1.3.1.0
    Thanks for any help,
    Glauco

    Yes, I have. This is the instructions that oracle gave me.
    There are two approaches:
    1) use WHILE bpel activity.
    a) Have a variable initially set to N, and loop it till it becomes Y.
    b) Inside the loop, you can have the assign activity, and human task call.
    c) If the humantask result is Reject,continue the loop again
    d) Else, set the variable as Y and end the loop
    2) Use scope
    For loopback process you can place the process in a scope and make use
    of the replay scope method to repeat the scope.
    a).Place the assign and UserTask in a single scope.
    b) For the Reject condition in the swtich activity , place a throw
    activity that throws a remoteFault.
    c). Put a catch around the scope to handle the fault thrown by the Reject condition.
    d). In this catch place a throw activity, with local part = replay. Choose the remoteFault fault and change de local part to replay
    e). This would replay the whole scope when the reject condition is meet.
    Both approaches work just fine.
    Glauco

Maybe you are looking for