3 Replies - 8952 Views - Last Post: 12 August 2009 - 06:17 AM Rate Topic: -----

#1 Choopa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 14-April 09

How can I make ArrayList of TextFields?

Post icon  Posted 12 August 2009 - 02:40 AM

I guess I've said everything in title :D
Thnx in advance...


love, Choopa
Is This A Good Question/Topic? 0
  • +

Replies To: How can I make ArrayList of TextFields?

#2 schultz2146  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 22-December 08

Re: How can I make ArrayList of TextFields?

Posted 12 August 2009 - 03:04 AM

View PostChoopa, on 12 Aug, 2009 - 01:40 AM, said:

I guess I've said everything in title :D
Thnx in advance...


love, Choopa

There is a good tutorial at http://java.sun.com/.../textfield.html on "How to Use Text Fields" give it a look over

ArrayList<String> nameArrayList = new ArrayList<String>()
JTextField nameTextField = new JTextField();

nameArrayList.add(nameTextField.getText())

/r
Richard
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,905
  • Joined: 06-March 08

Re: How can I make ArrayList of TextFields?

Posted 12 August 2009 - 05:17 AM

Not quite true
That is an ArrayList of the Text contained in JTextFields at ArrayList creation time
an ArrayList of JTextField that you can scan to get the ACTUAL JTextField contained text would be

ArrayList<JTextField> al = new ArrayList<JTextField>();
al.add(textField1);
al.add(textField2);
....
Was This Post Helpful? 0
  • +
  • -

#4 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2793
  • View blog
  • Posts: 15,901
  • Joined: 24-September 08

Re: How can I make ArrayList of TextFields?

Posted 12 August 2009 - 06:17 AM

Right, the cool thing about arraylists is that you can make them object types, meaning you can make and arraylist of a certain class. For example, I made an arraylist once so when I pressed the space bar I added a ball class instance in it and I had them looping so they bounced off the walls.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1