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?
Vector vecJCombobox1 = new Vector();
Vector vecJCombobox5 = new Vector();
Vector vecJTextfield1 = new Vector();
Vector vecJTextField5 = new Vector();
Thanks for your help...Ronnie
Vectors are thread-safe so they're a bit heavyweight. You can just use an ArrayList:
You will see from JComboBox's API:
...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:
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center