File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how to store datecombobox in an arraylist of type combobox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to store datecombobox in an arraylist of type combobox" Watch "how to store datecombobox in an arraylist of type combobox" New topic
Author

how to store datecombobox in an arraylist of type combobox

neha priya
Ranch Hand

Joined: Jul 03, 2010
Posts: 62
hello everyone,

i have a gui..in which i have two jcombobox and a datecombobx...now i want to store all of these in an arraylist of type JCombobox...how do i do it...


now




works fine but if i do

...i get an error regarding compatibility

please suggest some way so that am able to store dateComboBox in an arraylist of type JCombobox and also be able to retrieve the same as and when required.

thanks
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

try this

List<JComponent> comboOptionsList=new ArrayList<JComponent>();


Swastik
akhter wahab
Ranch Hand

Joined: Mar 02, 2009
Posts: 151

its not a good way.... but i think it might work

extend your DateComboBox from JComboBox . than add it...


Start Earning Online||Start Earning Using Java
neha priya
Ranch Hand

Joined: Jul 03, 2010
Posts: 62
@Swastik Dey:
thanks for the reply...

just one more query...if i declare the arraylist to be of type <JComponent> then when i execute the following statement

will i be able to get the string value that the user had entered in the jcombobox(age,name) or datecombobox(dob)??
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

Probably no you first need it to typecast it to appropriate type

for e.g.

Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4388
    
    8

Is this a com.jidesoft.combobox.DateComboBox?

The problem is that this and jaxax.swing.JComboBox are in a different inheritance hierarchy - so JComponent is the lowest class they both inherit from.

But, com.jidesoft.combobox.ListComboBox looks like it acts like a simple JComboBox. And both ListComboBox and DateComboBox inherit from com.jidesoft.combobox.AbstractComboBox, which contains the getSelectedItem() method.

So you should be able to do this:

neha priya
Ranch Hand

Joined: Jul 03, 2010
Posts: 62
@Matthew Brown:
thanks for replying...
yeah it is com.jidesoft.combobox.DateComboBox
i'll change all the jcombobox instances to ListComboBox..

tat should solve the problem i guess

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to store datecombobox in an arraylist of type combobox