• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

adding items in combo box?

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm really sorry! Will see to it that this wont happen next time! Cheers!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic