Results 1 to 5 of 5

Thread: the save button

  1. #1
    agater is offline Member
    Join Date
    Jul 2011
    Posts
    12
    Rep Power
    0

    Default the save button

    hi guys "

    I made a JFrame programm that consist of textField and I want to put a save button , that when I press it, it should save the text that I wrote it in the textField even if I cloesd the programm.


    what method should I use to make the save button work?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: the save button

    Are you trying to write the text to a text file? Are you trying to use persistence of some kind? Serialization? What have you tried so far? Where are you stuck?
    Last edited by KevinWorkman; 02-08-2012 at 09:09 PM.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: the save button

    Moving to the Swing forum -- nothing "advanced" about this question.

    I second Kevin's comments: you need to tell us a lot more about your problem and exactly where you're stuck if we're going to have a chance of being able to help you.

  4. #4
    agater is offline Member
    Join Date
    Jul 2011
    Posts
    12
    Rep Power
    0

    Default Re: the save button




    I made this counter programme , that every time I press the counter button it will increase the number on the text field.

    and I want to put a save button to work like this:

    for example on the programm above I reached number 8 if I press the save button it should save number 8 on the text field.

    and if I closed the programm and then open it again I should see number 8 on the text field.



    here is my code :

    PHP Code:
    counterButton.addActionListener(new Test());
    saveButton.addActionListener(new Test());
    }
    
    private class Test implements ActionListener
    {
    public void actionPerformed(ActionEvent e)
    {
    Object o = e.getSource();
    if (o.equals(counterButton))
    {
    ButtonClicks ++;
    }
    else
    {
    if (o.equals(saveButton))
    {
    
    ??????????????????
    
    }
    }
    lapel.setText("" + ButtonClicks );
    }
    }


    what should I write instead of the question mark to make the save button work.
    Last edited by agater; 02-09-2012 at 02:00 PM.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: the save button

    Then you have a couple of choices: easiest is to simply write it to a text file and read in the file on program start up. You also can use Properties which are also fairly easy to use.

Similar Threads

  1. How can i save the data Internally(auto save)
    By Rama Koti Reddy in forum AWT / Swing
    Replies: 2
    Last Post: 11-01-2010, 09:31 PM
  2. Save button not working
    By twinytwo in forum AWT / Swing
    Replies: 3
    Last Post: 03-28-2009, 01:05 AM
  3. Replies: 2
    Last Post: 03-26-2009, 05:15 AM
  4. Save button not working ,,,,,
    By twinytwo in forum AWT / Swing
    Replies: 3
    Last Post: 03-25-2009, 09:22 PM
  5. Disable Save button - Acrobar Reader
    By Deepa in forum New To Java
    Replies: 1
    Last Post: 03-06-2009, 01:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •