File chooser set directory

Is there any way of setting the directory the file chooser opens, as a default? If the files you are supposed to choose between are in the program's folder, I want the file chooser to open there, not somewhere else, so the user has to look around for the files... Anyone?

The APIs are your friend.
Love the APIs.
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JFileChooser.html#JFileChooser(java.io.File)

Similar Messages

  • Setting the UNIX file permissions after writing the file to a directory

    Hi Experts,
    Can we set the UNIX file permissions after writing the file to a directory using Receiver File Adpater in SAP PI 7.1 ?
    Thanks in Advance.
    Regards,
    Jyoti

    Hi
    you can use the option "Run Operatiing system Command after File Processing" in the file adapter.
    Thanks
    Rinku Gangwani

  • Post-Installation of RAC: main directory and file to set ORACLE_HOME ?

    Folks,
    Hello. I am installing Oracle 11gR2 RAC using 2 VMs (rac1 and rac2) whose OS are Oracle Linux 5.6 in VMPlayer according to the website http://appsdbaworkshop.blogspot.com/2011/10/11gr2-rac-on-linux-56-using-vmware.html
    I have just finished installing Grid infrastructure and RAC database 11gR2 successfully.
    After that, I add the entries into the file /home/ora11g/.bash_profile as below:
    export ORACLE_SID=racdb2;
    export ORACLE_HOME=/u02/11g_db/ora11g/racdb;
    export GRID_HOME=/u01/app/grid;
    PATH=$GRID_HOME/bin:$ORACLE_HOME/bin:$PATH; export PATH;
    After that, I run the following command:
    [ora11g@rac2 /]$ /u02/11g_db/ora11g/racdb/bin/srvctl config database -d racdb
    Its output:
    ORACLE_HOME environment variable is not set.
    ORACLE_HOME should be set to main directory that contains Oracle products.
    Set and export ORACLE_HOME and then re-run.
    My questions are:
    First, I have added entries into the file /home/ora11g/.bash_profile. Why it still says "ORACLE_HOME environment variable is not set" ? Is this way wrong ?
    Second, what are the main directory and the file to set ORACLE_HOME ?
    Thanks.

    Folks,
    Hello. Thanks a lot for replying. I reboot OS and run the commands as below:
    [ora11g@rac2 bin]$ ./srvctl config database -d racdb
    Its output:
    PRCD-1027 : Failed to retrieve database racdb
    PRCR-1070 : Failed to check if resource ora.racdb.db is registered
    Cannot communicate with crsd
    [ora11g@rac2 bin]$ ./sqlplus
    SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 9 15:28:59 2012
    Copyright (c) 1982, 2009, Oracle. All rights reserved.
    Enter user-name: SYS
    Enter password: SYS
    ERROR:
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux-x86_64 Error: 2: No such file or directory
    Process ID: 0
    Session ID: 0 Serial number: 0
    Enter user-name: SYSTEM
    Enter password: SYSTEM
    ERROR:
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux-x86_64 Error: 2: No such file or directory
    Process ID: 0
    Session ID: 0 Serial number: 0
    Enter user-name: SYSMAN
    Enter password: SYSMAN
    ERROR:
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux-x86_64 Error: 2: No such file or directory
    Process ID: 0
    Session ID: 0 Serial number: 0
    SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
    [ora11g@rac2 bin]$
    As we see the outputs above for the 2 commands "srvctl" and "sqlplus", my questions are:
    First, why cannot retrieve database racdb ?
    Second, sqlplus is poped up. Why users SYS, SYSTEM, SYSMAN cannot log in ?
    Third, does my RAC database installation have problems ?
    Thanks.

  • Fm to choose a file from a directory

    can anybody tell me the fm used to choose a file from a directory
    thnks

    On the selection screen, do F4 help on the P_FILE parameter.
    report zrich_0001.
    DATA: v_rc TYPE i.
    DATA: lt_filetab TYPE filetable.
    DATA: ls_filetab LIKE LINE OF lt_filetab.
    PARAMETERS: p_file TYPE localfile.
    AT SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        CHANGING
          file_table              = lt_filetab
          rc                      = v_rc
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      READ TABLE lt_filetab INTO ls_filetab INDEX 1.
      IF sy-subrc = 0.
        p_file = ls_filetab-filename.
      ENDIF.
    start-of-selection.
    Regards,
    Rich Heilman

  • URGENT: Choosing target directory according to file name.

    Hi
    I have a requirement for transfering a file to the directory according to the filename.
    Example
    If the file name is
    FIABC it should be moved to directory DI_ABC in the target server and if it is
    FIXYZ it should be moved to directory DI_XYZ.
    No mapping is involved in this case .
    Do we have some other way around than variable substituion
    Regards
    Abhishek mahajan

    Hi,
    For this we have to configure Two Communication Channels one for one Location and the other for other location.
    Use X-path concept in Interface Determination and call the corresponding inbound Message Interface and Interface Mappings based on the condition
    1) Create Two Inbound MI's
    2) Create One MM
    3) Create 2 Interface Mappings
    4) Create 2 Receiver CC and One Sender CC
    5) Create One Receiver Det
    6) Create 2 Interface Det
    7) Create One Sender Agreement
    8) Create Two Receiver Agreements
    Regards
    Seshagiri

  • File Chooser is displaying names of the Files and Directories as boxes

    Hi All,
    Actually i am working on an application in which i have the requirement to internationalize the File Chooser in All Operating Systems. The application is working properly for all languages on MAC OS, but not working properly for the language Telugu on both the Ubuntu and Windows OS. The main problem is, when i try to open the File Chooser after setting the language to TELUGU all the labels and buttons in the File Chooser are properly internationalized but names of Files and directories in the File Chooser are displaying as boxes.
    So please provide your suggestions to me.
    Thanks in Advance
    Uday.

    I hope this can help you:
    package it.test
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Locale;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    * @author Alessandro
    public class Test extends JDialog {
         private JFileChooser fc = null;
         private Frame bfcParent = null;
         public Test(Frame parent, boolean modal) {
              super(parent, modal);
              this.bfcParent = parent;
              if (fc == null) {
                   fc = new JFileChooser();
                   fc.setAcceptAllFileFilterUsed(false);
                   fc.setLocale(Locale.ITALIAN);//i think you should use english
                   //these are in telugu
                   UIManager.put("FileChooser.openDialogTitleText", "Open Dialog");
                   UIManager.put("FileChooser.saveDialogTitleText", "Save Dialog");
                   UIManager.put("FileChooser.lookInLabelText", "LookIn");
                   UIManager.put("FileChooser.saveInLabelText", "SaveIn");
                   UIManager.put("FileChooser.upFolderToolTipText", "UpFolder");
                   UIManager.put("FileChooser.homeFolderToolTipText", "HomeFolder");
                   UIManager.put("FileChooser.newFolderToolTipText", "New FOlder");
                   UIManager.put("FileChooser.listViewButtonToolTipText", "View");
                   UIManager.put("FileChooser.detailsViewButtonToolTipText", "Details");
                   UIManager.put("FileChooser.fileNameHeaderText", "Name");
                   UIManager.put("FileChooser.fileSizeHeaderText", "Size");
                   UIManager.put("FileChooser.fileTypeHeaderText", "Type");
                   UIManager.put("FileChooser.fileDateHeaderText", "Date");
                   UIManager.put("FileChooser.fileAttrHeaderText", "Attr");
                   UIManager.put("FileChooser.fileNameLabelText", "Label");
                   UIManager.put("FileChooser.filesOfTypeLabelText", "filesOfType");
                   UIManager.put("FileChooser.openButtonText", "Open");
                   UIManager.put("FileChooser.openButtonToolTipText", "Open");
                   UIManager.put("FileChooser.saveButtonText", "Save");
                   UIManager.put("FileChooser.saveButtonToolTipText", "Save");
                   UIManager.put("FileChooser.directoryOpenButtonText", "Open Directory");
                   UIManager.put("FileChooser.directoryOpenButtonToolTipText", "Open Directory");
                   UIManager.put("FileChooser.cancelButtonText", "Cancel");
                   UIManager.put("FileChooser.cancelButtonToolTipText", "Cancel");
                   UIManager.put("FileChooser.newFolderErrorText", "newFolder");
                   UIManager.put("FileChooser.acceptAllFileFilterText", "Accept");
                   fc.updateUI();
         public int openFileChooser() {
              fc.setDialogTitle("Open File");
              fc.resetChoosableFileFilters();
              int returnVal = 0;
              fc.setDialogType(JFileChooser.OPEN_DIALOG);
              returnVal = fc.showDialog(this.bfcParent, "Apri File");
              //Process the results.
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                   System.out.println("Hai scelto di aprire un file");
              } else {
                   System.out.println("hai annullato l'apertura");
              return returnVal;
         private static void createAndShowGUI() {
              JFrame frame = new JFrame("FileChooser");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel jp = new JPanel(new BorderLayout());
              JButton openButton = new JButton("Open File");
              final Test test = new Test(frame, true);
              openButton.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        test.openFileChooser();
              openButton.setEnabled(true);
              jp.add(openButton, BorderLayout.AFTER_LAST_LINE);
              //Add content to the window.
              frame.add(jp);
              //Display the window.
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args) {
              //Schedule a job for the event dispatch thread:
              //creating and showing this application's GUI.
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        //Turn off metal's use of bold fonts
                        createAndShowGUI();
    }bye ale

  • Upload attachment using BPM File Chooser in OBPM 10g

    Hi,
    I am currently working on OBPM 10g.
    Can anyone please help me with upload attachment using BPM File Chooser using BPM Presentation?????

    Do not use the existing Fuego.Ui.FileChooser component. This OOTB Oracle BPM component would work fine if you're trying to get a file from the server where the Engine is running, but will not work if you want a file from the end user client's machine.
    Take a look at a project I uploaded to http://www.4shared.com/file/aq-cY2qN/_2__FileChooserDemo.html
    It has both a JSP and a BPM Object presentation. The BPM Object presentation has a button called "Attach File", If you click in the presentation editor and then click the Properties tab you'll see that its "Name" property is "AttachFile" and the Action property is set to "submit". This means that it will return the text "AttachFile" in the result predefined variable in the screenflow. If you open the screenflow, you'll see the conditional transition from the "AttachmentViewerInteractive" to the "FileChooser" task. The name of this transition is "AttachFile". Because this was named "AttachFile", the logic behind this transition evaluates if "result ==AttachFile".
    Be careful with this example project. It will succeed when a small text or binary file < 100k is selected. It will go to the "File is too big" task in the screenflow shown below when the file > 100k. To make this maximum size limit larger, simply add a new line in your
    <Oracle BPM Enterprise Home Directory>\webapps\workspace\WEB-INF\workspace.properties file:
    # Max size of a file coming from a client machine (default is 100k)
    fuego.workspace.servlet.Attachment.MAX_ATTACHMENT_SIZE=2000000
    Once the file has been retrieved, do not store this as an instance variable unless it has been marked as a “Separated” instance variable.
    The “AttachView1.jsp” is invoked from the Interactive activity’s “FileChooser” task in the screenflow.
    Once the end user selects the file from the JSP, work flows to the “Add file” task. This is where you can retrieve the selected file’s:
    - Name: fileHolder.file_filename variable
    - Content type: fileHolder.file_content_type variable
    - Contents: fileHolder.file binary variable
    Dan

  • "Unable to set directory" on Seagate 500gb Backup Plus USB Hard Drive

    I recently purchased a Macbook Pro as of today, I'm upgrading from windows, and I'm having issues trying to set up my external hard drive to download torrent files. I know with Windows, I can plug in the hard drive cfrom windows computer to another windows computer and have no issues with downloading torrent files. When I tried to get the torrent to download a file onto the external hard drive I recieved this error message:
    Unable to set directory
    Don't have enough permissions to write to '/Volumes/Seagate Backup Plus Drive'. Please choose another directory.
    I'm currently using uTorrent to download Bit Torrent files. I also tried to move files already on the external hard drive into another folder on the same hard drive, and it will not allow me to move the files.
    I was wondering if anyone knows of a solution to this problem?

    I managed to fix the issue

  • Ssis - move files from one directory to another and rename destination file if present

    Hello,
    How is it possible to move files from one directory to another directory and if the file already exists in destination directory then rename it?
    Thanks

    1. Use a foreach loop with file enumerator pointing to first directory.
    Inside loop have a ssis variable of type string to get filename (@[User::FileName])
    Choose option as Fully Qualified in loop
    2. Add another variable called @[User::DestFileName], set EvaluateAsExpression true for it and set expression like this
    REPLACE(@[User::FileName],<source directory path>,<destination directory path>)
    put actual paths in above expression in your case
    and another variable called @[User::RenameFileName], set EvaluateAsExpression true for it and set expression like this
    REPLACE(@[User::FileName],".","_old.")
    3. Create a boolean variable say @[User::FileEXists]
    4. Add a Script Task inside the loop and pass @DestFileName variable in ReadOnly mode and FileExists in ReadWrite mode
    Inside Script Task write code as per below
    http://blog.dbandbi.com/2013/11/13/check-file-exists-ssis/
    5. Add File System Task choose operation as Rename File, Select IsSourcePathVariable as true and select @[user::DestFileName] variable and IsDestinationPath variable as true and select @[user::RenameFileName] variable
    6. Choose ExpressionAndConstraint option for precedeence constraint from ScriptTask to above File System Task and choose constraint as OnSuccess and expression as
    @FileExists == True
    7. Add another File System task with operation as Move File Select IsSourcePathVariable as true and select @[user::FileName] variable and IsDestinationPath variable as true and select @[user::DestFileName] variable. Join Script Task as well as
    File System Task above to this task and choose constraint as OnSuccess and Multiple Constraint option as Or (dotted line)
    Then once executed it will work as per your requirement
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Upload all the files in a directory

    Hi,
    I have searched in forum for a solution to my problem (Upload all the files contained in a certain directory) but all I've found is solutions to upload a single file using the bean JspSmartUpload. I had myself used this bean to uploads files to an server, but files choosed by the user with the <input type="file">. What I'm wanting know is different and I can't find a solution to it. I've tried to change the jspsmartupload to do this but I'm having no success..
    Anyone can help?
    Thanks in advance,
    Nuno.

    I don't believe there's any support in pure html forms to accomplish this.
    The File class has a listFiles() method, that will return an array of all the files in a directory. As this code must run on the client machine, you will need to write an applet to accomplish this. You will also have to worry about the security sandbox, and sign your applet.
    To get each file to the server you will need to create a URL object, openConnection on it, set up a multipart form POST to it, and transfer the files, one by one.

  • Set Directory

    hi,
    could someone let me know how i can set the current directory
    i am saving the contents of a table as follows,
    using fileChooser to enter the name of the file, then passing this file name to another method in a different class which does the dirty work.
    void menuSave_actionPerformed(ActionEvent e){
       chooser.setCurrentDirectory(new File("./Save"));
       int returnVal = chooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION)
      File file = chooser.getSelectedFile();
      tableTrack.save_table(file.getName());
           }**the save table Method in another class**
    FileOutputStream fStream = new FileOutputStream("" + fileSaveName + "");
              ObjectOutputStream oStream = new ObjectOutputStream(fStream);
              oStream.writeObject(data);
              oStream.flush();
              fStream.close();is there a way to set the directory in this second method??
    I have tired using
    FileOutputStream fStream = new FileOutputStream("./SAVE" + fileSaveName + ""); but this simply adds the string ./Save to the file name. As no directory is set, All saved files are made in the same directory the code is compiled in.
    cheers for any help.
    RC

    hi,
    cheers!
    is it not possible to use the two dots as in
    [/code[
    Full paths have the obvious problems!                                                                                                                                                                                                                                               

  • JFileChooser - Select All Files in the Directory

    Hi all. I am currently using JFileChooser and I need a functionality that will let the user choose a directory and then automatically select all the files that exists in that directory. I have tried looking around for references, but no luck so far. I hope someone can help. Thanks in advance.

    This is what I use frequently in my applications :
    * Requests the loading of all Images
    * in a directory.
    private void loadImageDirectory() {
      //create a FileFilter so the user only sees directories     
      javax.swing.filechooser.FileFilter dirfilter=new javax.swing.filechooser.FileFilter() {
        public boolean accept(File f) {
          if(f==null)
            return false;
          if(!f.isDirectory())
            return false;
          return true;
        public String getDescription() {
          return "Directories only";
      //now create the filechooser     
      JFileChooser jfc=new JFileChooser();
      jfc.setDialogTitle("Select a directory");
      jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      //remove the standard FileFilters (otherwise shows files too     
      jfc.resetChoosableFileFilters();
      //Set a FileFilter for directories only
      jfc.addChoosableFileFilter(dirfilter);
      int result=jfc.showOpenDialog(this);
      jfc_image_dir=jfc.getCurrentDirectory();
      if(result==JFileChooser.APPROVE_OPTION) {
        //here i call a method that does something with the directory     
        iv.addDirectory(jfc.getSelectedFile());
    }This always worked for me ??
    You might want to try??

  • Script to open all PST files in a directory and open with Outlook.

    Hi!  I am looking for a script that opens all PST files in a directory, opens it in outlook, and writes to a log to see if it completed correctly.  I'm new to VBscript and just want to see how the script would be written.
    Thank you!!

    Thank you for all the input!  JRV, I went through the repository and couldn't find anything about importing into Outlook.  I will use it for future references and I appreciate you directing me there.
    Grant, I need to be able to locate all PST files within a directory, not point it to a specific pst.  I also need it written to a log file.  Here is what I have...Don't laugh, I'm very new...
    const ForAppending = 8
    set objTextFile = objFSO.OpenTextFile ("C:\Users\jimmy.nguyen\Desktop\Lucky.txt", ForAppending, True)
    set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("WScript.Shell")
    strCommand = "C:\Program Files (x86)\Microsoft Office\Office12\outlook.exe"
    Set objExecObject = objShell.Exec(strCommand)
    wscript.sleep 4000
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNS = myolapp.GetNamespace("MAPI")
    myNS.AddStore "objfile.name"
    Sub ShowSubFolders(fFolder)
    Set objFolder = objFSO.GetFolder(fFolder.Path)
    Set colFiles = objFolder.Files
    For Each objFile in colFiles
    If UCase(objFSO.GetExtensionName(objFile.name)) = "pst" Then
    objFile.Name
    End If
    Next
    For Each Subfolder in fFolder.SubFolders
    ShowSubFolders(Subfolder)
    Next
    End Sub
    strResults = ShowSubFolders(fFolder)
    objTextFile.WriteLine(strResults)
    objTextFile.Close

  • Need help adding a default file name in a file chooser of save dialog type

    I need to create a file chooser with save dialog type, how can I add a highlighted default file name into the File Name textfield? As in Microsoft Word, when you want to save a document, a default file name Doc1.doc will appear in the File name text field of the file chooser even when you change to other directories.

    For JRE 1.4.0 you can use this fix:
    public class FileChooserFix implements PropertyChangeListener {
      private String fileName;
       * @see PropertyChangeListener
      public void propertyChange(PropertyChangeEvent ev) {
        JFileChooser chooser = (JFileChooser)ev.getSource();
        if (JFileChooser.FILES_ONLY == chooser.getFileSelectionMode()) {
          if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            File selectedFile = (File)ev.getNewValue();
            if (selectedFile != null) {
              // remember fileName of selected file
              fileName = selectedFile.getName();
          if (fileName != null &&
              JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            // reset selected file
            File directory = (File)ev.getNewValue();
            chooser.setSelectedFile(new File(directory, fileName));
       * Convenience method to create a fixed file chooser.
       * @return      fixed file chooser
      public static JFileChooser create() {
        JFileChooser chooser = new JFileChooser();
        chooser.addPropertyChangeListener(new FileChooserFix());
        return chooser;

  • Default settings for File Chooser dialog

    I reach the file chooser dialog by selecting File-Open File.
    Under the toolbar-options menu in the Open File Dialog, I can select to have a bookmark icon appear on the toolbar.
    How do I set a default to have the Bookmark icon always appear?
    Firefox 11 on openSuSE 12.1

    I don't think so, if I hide the Menu bar I don't see a Bookmarks Menu.
    In this picture http://dl.dropbox.com/u/50261731/Open_File%20Menu%20.png an arrow points to an Options menu button. Select that Button and a list of options opens, one of which is "Show Bookmarks". I would like the Show Bookmarks option to be "ON" by default.
    Be aware that I am running SuSE 12.1 and I believe this Menu is provided by KDE integration "kmozillahelper", so my menu may be different from the default Firefox menu.

Maybe you are looking for