• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Jcombo box

 
Ranch Hand
Posts: 158
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All.

I am fetching all data into combobox. Like
1 = Pepsi
2 = Marinda
3 = CocaCola
4 = Sprite
5 = 7Up

I want that user can only be enable to select "Pepsi and Sprite" the rest of the data must appear into combobox but selection of "Marinda,CocaCola and 7Up" would not be from user.

Can anyone help me out.
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok...what i understand is...... u want to list all the items in
combobox BUT do not let the user to select the 3 items. right?

Im not sure if there is any such method to do it.... however,

how abt checking for these values in actionperformed method
and if matched, do nothing??
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pls take a look at JComboBox and ItemSelectable API. That will help you.

--
./pope
[the_mindstorm]
 
Anand Karia
Ranch Hand
Posts: 158
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one send me an example with code.
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have ever been in Desktop Application Development using Swing before. I have never seen such feature in JComboBox... I think the most feasible way to fulfil this requirement is to listen for the items that the user tries to choose and react according to his/her choice... But if there is a direct way to implement, it would be better...

Hints as per my suggestion:
-add an ItemListener
-implement itemStateChanged(ItemEvent e)
-check by the items' indices

Hope it helps...
reply
    Bookmark Topic Watch Topic
  • New Topic