• Post Reply Bookmark Topic Watch Topic
  • New Topic

adding items in combo box?

 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

Help me out with this small issue! How do you add items in combo box from back end? Its clear with list but i don't know the functions used for combo box! In list I used a vector and added elements to list by "listname.setListData(vectorname)" .. Can a combo box accept data from vector? If so what is the function to do that? Else what am I supposed to do to add items?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"listname.setListData(vectorname)" does not add items.
It displays a whole new set of data.
What exactly are you trying to do?
Add an item to the existing ones in the JComboBox or display a new data set?
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep Swaminathan wrote:
How do you add items in combo box from back end? Its clear with list but i don't know the functions used for combo box! ... Can a combo box accept data from vector?


A combo box can definitely "accept data" from a DefaultComboBoxModel, which is a lot like a Vector:
 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops! I didnt mean that .. Sorry! I knew that it displays items .. Well I solved the issue and thanks a lot for your time .. I really appreciate them .. thanks again
 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well well .. I have another doubt! How do you check whether an item from a combo box is selected or not? Would like to know whether JComboBox.getSelectedItem() has been chosen or not? Must return a boolean variable.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep Swaminathan wrote:Well well .. I have another doubt! How do you check whether an item from a combo box is selected or not? Would like to know whether JComboBox.getSelectedItem() has been chosen or not? Must return a boolean variable.


If it is chosen, it has to be selected right?
So you take the selected item and compare it with your item and figure out the boolean.
There is no ready made method like myCombo.isSelected(Object myItem) which will return a boolean.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sandeep,
Please spawn a new thread for a new question.
I am deleting your new question post from this thread.
 
Sandeep Swaminathan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm really sorry! Will see to it that this wont happen next time! Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!