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

how to render a Combobox (or other things) in just one Cell

 
Jason Richard
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm sure that there is an answer somewhere for this, but everything i look for seems to be specific for an entire column.

what i have is a JTable. This JTable is used for user preferences. I want to have certain CELLS to have a JComboBox.

So in Column 1, row 1,row2,row3, and row 4 would all be just normal Text, but Column 1 Row 5 is a JComboBox with particular values. Thus far it's been all or nothing.

Any thoughts?
 
Rob Camick
Ranch Hand
Posts: 2475
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Override the getCellEditor() method of JTable. In the example below a comboBox editor is displayed in rows 0, 1, 2. All other rows use the default editor:


 
Jason Richard
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Rob,

You sir are a fine Gentleman, and I wish you many happy days doing whatever it is you love to do. If there is a way to make sure this post comes up when somebody googles "how do i render a JComboBox in just one particular cell of a JTable, and not in every row of that column", then you will make somebody else as happy as I am now.

I didn't implement it exactly, but



hot darn that was what i needed


Thanks again!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic