Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I want to limit selectable values in Combobox  RSS feed

 
Phillip Ankerson
Greenhorn
Posts: 27
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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
    Java MySQL Database Netbeans IDE
    • Mark post as helpful
    • send pies
    • 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?
     
    Rob Camick
    Ranch Hand
    Posts: 2800
    15
    • Mark post as helpful
    • send pies
    • 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.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!