This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to store datecombobox in an arraylist of type combobox

 
neha priya
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this

List<JComponent> comboOptionsList=new ArrayList<JComponent>();
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably no you first need it to typecast it to appropriate type

for e.g.

 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • 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
  • 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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic