| Author |
Why we dont have JComboBox(ArrayList items)
|
Vikas Kumar Sahu
Ranch Hand
Joined: Dec 02, 2003
Posts: 59
|
|
Hi All, I have seen JCombobox API and found JComboBox(Vector items) constructor. But why we dont have JComboBox(ArrayList items) constructor having array list as argument. R Vikas Sahu
|
 |
Vijay Vaddem
Ranch Hand
Joined: Feb 13, 2004
Posts: 243
|
|
Its ok Vikas.............. But it does take a string array .... right? To convert a arraylist to string [], do this.... Probably its just bcos we need to do some work!! Cheers, Vijay
|
 |
Vikas Kumar Sahu
Ranch Hand
Joined: Dec 02, 2003
Posts: 59
|
|
|
Thanx Vijay.
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
Or we can use this constructor JComboBox(Object[] items) which creates a JComboBox that contains the elements in the specified array. You might use like this... JComboBox(urArrayList.toArray()) You will get the same objects inside your JComboBox... To minimize the redundancy, Sun might not include JComboBox(ArrayList items) which can be simulated by the method mentioned above...
|
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
|
 |
 |
|
|
subject: Why we dont have JComboBox(ArrayList items)
|
|
|