How to add a feature to save a file in GUI


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: How to add a feature to save a file in GUI

  1. #1
    Mallu Guest

    How to add a feature to save a file in GUI


    I have created the file menu. In that I have saveAs Icon. Once the user clicks
    on that Icon, how to save the file?

  2. #2
    Rob Abbe Guest

    Re: How to add a feature to save a file in GUI


    Depends on what you are trying to save.

    What you are interested in is streams and buffers. Check out the documentation
    for the java.io package on Suns website. The following may get you started.
    It simply opens a file and writes a line of data followed by a blank line.
    Then closes the file.

    import java.io.BufferedWriter;
    import java.io.FileWriter;

    public class Test {
    private void makeData(String fileName) {
    // Open the datafile.
    FileWriter outFile = new FileWriter(fileName);
    BufferedWriter buff = new BufferedWriter(outFile);

    // Write out some data.
    buff.write("This is some data");
    buff.newLine();

    // Close the file.
    buff.close();
    outFile.close();
    }

    public static void main(String[] args) {
    makeData("rob.txt");
    }
    }


    "Mallu" <java.@127.0.0.1> wrote:
    >
    >I have created the file menu. In that I have saveAs Icon. Once the user

    clicks
    >on that Icon, how to save the file?



  3. #3
    Rob Abbe Guest

    Re: How to add a feature to save a file in GUI


    Or were you wanting to know how to setup the event in order to save the file?
    If what I have provided is not enough, please provide more info.

    Thanks

    "Rob Abbe" <rabbe@mn.rr.com> wrote:
    >
    >Depends on what you are trying to save.
    >
    >What you are interested in is streams and buffers. Check out the documentation
    >for the java.io package on Suns website. The following may get you started.
    > It simply opens a file and writes a line of data followed by a blank line.
    > Then closes the file.
    >
    >import java.io.BufferedWriter;
    >import java.io.FileWriter;
    >
    >public class Test {
    > private void makeData(String fileName) {
    > // Open the datafile.
    > FileWriter outFile = new FileWriter(fileName);
    > BufferedWriter buff = new BufferedWriter(outFile);
    >
    > // Write out some data.
    > buff.write("This is some data");
    > buff.newLine();
    >
    > // Close the file.
    > buff.close();
    > outFile.close();
    > }
    >
    > public static void main(String[] args) {
    > makeData("rob.txt");
    > }
    >}
    >
    >
    >"Mallu" <java.@127.0.0.1> wrote:
    >>
    >>I have created the file menu. In that I have saveAs Icon. Once the user

    >clicks
    >>on that Icon, how to save the file?

    >


  4. #4
    Guest

    Re: How to add a feature to save a file in GUI


    "Mallu" <java.@127.0.0.1> wrote:
    >
    >I have created the file menu. In that I have saveAs Icon. Once the user

    clicks
    >on that Icon, how to save the file?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center