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 5 of 5

Thread: save button in java

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default save button in java

    i have created code for save button the code worked but the saved file was not in the specified location please help.. the code is


    JFileChooser chooser_save=new JFileChooser();
    chooser_save.showSaveDialog(null);
    File file=chooser_save.getSelectedFile();


  2. #2
    Member vigneshwaran's Avatar
    Join Date
    Nov 2012
    Location
    Chennai, TamilNadu
    Posts
    35
    My Mood
    Cheerful
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: save button in java

    what u are doing in File file=chooser_save.getSelectedFile(); ??

    what u want in actual?

    i guess , the code should looks like this,
    File file=chooser_save.getSelectedFile().getPath();

  3. #3
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: save button in java

    @vigneswaran: that wom't compile. getPath() returns a String.

    @OP: print the value of file to check that it names the file you think it should. If there is a problem consider posting enough code so that people can see what is going on.

  4. #4
    Junior Member
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: save button in java

    actually i have created a button named save and a text field, and while saving a file i want it to be written into the text field and the savebutton to save the file in specified location please help me

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

    Default Re: save button in java

    Please post a small complete program that compiles, executes and shows the problem.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Save java frame as pdf/image.
    By Austin777 in forum Java Theory & Questions
    Replies: 6
    Last Post: October 16th, 2012, 08:01 AM
  2. How to save Image into a package by JButton save?
    By justyStepi in forum AWT / Java Swing
    Replies: 1
    Last Post: May 12th, 2012, 07:02 PM
  3. Read modify save xml elements in java
    By karthikin in forum Member Introductions
    Replies: 2
    Last Post: June 27th, 2011, 08:05 AM
  4. Java JTextPane Save
    By ikurtz in forum File I/O & Other I/O Streams
    Replies: 9
    Last Post: April 28th, 2010, 01:02 AM

Tags for this Thread