permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes Why we dont have JComboBox(ArrayList items) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Why we dont have JComboBox(ArrayList items)" Watch "Why we dont have JComboBox(ArrayList items)" New topic
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Why we dont have JComboBox(ArrayList items)
 
Similar Threads
adding items to jcombo box
Small Question Regarding JComboBox
cannot find symbol
How to handle more than two combobox
JTable selected row problem