Using Java Vectors?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Using Java Vectors?

  1. #1
    Join Date
    Sep 2003
    Posts
    36

    Using Java Vectors?

    I am used to VB's dynamic data statements with the Redim abilities and was wondering if Java's Vectors would provide the similiar options. Also, had a vector/variable question.

    I am writting a program which accepts input from 5 JComboboxs and 5 Jtextfields. There can be several (exact number unknown) imputs per user. That is I have one user with several accounts (Records) per input.

    I want to use arrays but, think Java's vector would be more appropreate.

    1) Am I correct?

    2) Does each JCombobox and JTextfield need its own Vector object?

    That is:

    Vector vecJCombobox1 = new Vector();
    .
    .
    Vector vecJCombobox5 = new Vector();

    Vector vecJTextfield1 = new Vector();
    .
    .
    Vector vecJTextField5 = new Vector();

    Thanks for your help...Ronnie

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    Vectors are thread-safe so they're a bit heavyweight. You can just use an ArrayList:

    http://java.sun.com/j2se/1.3/docs/ap...ArrayList.html

    You will see from JComboBox's API:

    http://java.sun.com/j2se/1.3/docs/ap...JComboBox.html

    ...that you can pass in a Vector into the constructor which will be used as the data source for the Vector. However, you can just use the default constructor and then repeatedly called addItem method:

    http://java.sun.com/j2se/1.3/docs/ap...x.html#addItem(java.lang.Object)
    ArchAngel.
    O:-)

  3. #3
    Join Date
    Sep 2003
    Posts
    36
    Thanks...

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