• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

how to store datecombobox in an arraylist of type combobox

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this

List<JComponent> comboOptionsList=new ArrayList<JComponent>();
 
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its not a good way.... but i think it might work

extend your DateComboBox from JComboBox . than add it...
 
neha priya
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably no you first need it to typecast it to appropriate type

for e.g.

 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic