Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: JFileChooser with String var from CONFIG file - not setting default directory

  1. #1
    Junior Member
    Join Date
    Aug 2021
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JFileChooser with String var from CONFIG file - not setting default directory

    Trying to create JFileChooser and set the current directory DOES WORK in these instances:
    1) Instantiating JFileChooser with a string LITERAL
    2) Instantiating JFileChooser with a string VAR initialized with a string LITERAL
    3) Instantiating JFileChooser with a string VAR initialized with another string VAR

    Trying to create JFileChooser and set the current directory DOES NOT WORK in these instances:
    4)
    String backupLoc;
    codeContext = new AnnotationConfigApplicationContext(BackupConfig.cl ass);
    backupLoc = (String) codeContext.getBean("backupLocation");
    JFileChooser fileChooser = new JFileChooser(backupLoc);
    5)
    String backupLoc;
    codeContext = new AnnotationConfigApplicationContext(BackupConfig.cl ass);
    backupLoc = (String) codeContext.getBean("backupLocation");
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setCurrentDirectory(new File(backupLoc));

    Thanks in advance...

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: JFileChooser with String var from CONFIG file - not setting default directory

    Did you have code you are having problems with?
    Please post the code (wrapped in code tags)
    and the compiler's error messages
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] JFileChooser provides null string
    By stewbond in forum AWT / Java Swing
    Replies: 2
    Last Post: November 1st, 2013, 05:54 PM
  2. Replies: 3
    Last Post: June 26th, 2013, 02:12 AM
  3. Setting up Directory Structure in Java Applications
    By Jyotirmoy in forum Member Introductions
    Replies: 0
    Last Post: July 28th, 2011, 05:28 AM
  4. What's wrong with my code for remembering JFileChooser's Last Directory?
    By esplanade56 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 18th, 2011, 08:23 AM
  5. JFileChooser setting directory
    By fox in forum AWT / Java Swing
    Replies: 2
    Last Post: February 18th, 2011, 11:58 AM