Results 1 to 3 of 3
  1. #1
    Lehane_9 is offline Member
    Join Date
    Dec 2007
    Rep Power

    Arrow getting the value of variable

    public void actionPerformed(ActionEvent e)

    if (!txtBox.getText().equals("")){
    int a = 0;

    for(int i = 0; i < combo.getItemCount(); i++){
    a = 1;
    if (a == 1)
    JOptionPane.showMessageDialog(null,"Combo has already this item.");



    // I want to store the value of txtBox.text(), to an array and then to a file,
    if some could show me how to do this it would be appreciated as i have tried for about an hour and a half myself.
    thank you in advance!!

  2. #2
    gibsonrocker800's Avatar
    gibsonrocker800 is offline Senior Member
    Join Date
    Nov 2007
    New York
    Rep Power


    Well, what do you about arrays, and FileWriting?

    If you don't know how to use arrays, you should learn how. And, you will need to learn about the FileWriter class. (Or BufferedWriter, or PrintWriter).

    Just let us know what you know so we can assist you.

  3. #3
    Leprechaun is offline Member
    Join Date
    Dec 2007
    Rep Power


    You'll probably want an array list since you don't know how many items you'll be getting.
    import java.util.ArrayList; // import
    ArrayList<String> items = new ArrayList<String>(); // how to declare one
    and then each time you find a new item and add it to the combo just add this line with it:
    As for writing it to a file, that's kind of complicated...

Similar Threads

  1. Increment a Variable
    By rhm54 in forum New To Java
    Replies: 2
    Last Post: 06-14-2008, 02:57 AM
  2. Getting variable value from a variable name
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-16-2008, 09:26 PM
  3. Variable No. of Arguments
    By Gajesh Tripathi in forum New To Java
    Replies: 2
    Last Post: 10-31-2007, 02:50 PM
  4. Create a new variable
    By mathias in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:48 AM
  5. String Variable
    By Eric in forum Advanced Java
    Replies: 1
    Last Post: 06-06-2007, 04:30 AM

Posting Permissions

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