• 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

I want to limit selectable values in Combobox

 
Greenhorn
Posts: 27
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a simple combobox with two columns

CoreNum | UsedFlag

I want all values to be displayed. However, if the Usedflag value is 0, I want to prevent it from being selectable, but still display (i.e.grayed out).

Snippet:


Entity class snippet:


Trying to catch on...Thank you.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're complicating your problem with the two-column renderer. As I see it, the actual problems are:
  • rendering 'disabled' items in gray -- a job for the renderer
  • preventing their selection -- a job for the selection model


  • Here's a short example of both (thanks to Jeanette on the OTN for the code to access a JComboBox's dropdown list). It has a shortcoming in that if the first item is non-selectable, it still appears as the initial selected value. I'll leave that for you to tackle.

     
    Phillip Ankerson
    Greenhorn
    Posts: 27
    Netbeans IDE MySQL Database Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The reason I need two columns is because the user needs to see the core numbers and which ones are available. I suppose I could limit the query to those core numbers that are available (used_flag = 0). I have seen two column drop-downs before; maybe I should use something other than a Combobox?
     
    Rancher
    Posts: 3324
    32
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    I could limit the query to those core numbers that are available (used_flag = 0).



    That would be my vote.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic