File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
 
Consider Paul's rocket mass heater.
 
subject: Why we dont have JComboBox(ArrayList items)