• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using Comboboxes with JTable where first row displaying comboxes.  RSS feed

 
Mohammed Ajmal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hell�,

I need information on using ComboBoxes as Tablecolumns of JTable.
The requirement is like below the TableHeader which has columns combo boxes should appear.That is first row of table should contain combo boxes which contains all values of that column. So that user can filter by selecting the value or entering some search criteria. It is similar to excel format where user can pick values from list.

Could anyone post some sample code or links where such examples or tutorials describes about comboboxes usage as I require.

Thanks.
 
Sunil Kumar Gupta
Ranch Hand
Posts: 824
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html


Enjoy
 
Brian Cole
Author
Ranch Hand
Posts: 936
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mohammed Ajmal:
The requirement is ... below the TableHeader ... combo boxes should appear. That is first row of table should contain combo boxes which contains all values of that column.


Presuming that subsequent rows should not have these
combo-boxes, then you must create a TableCellEditor that
returns the combo box editor when the row parameter is zero
in its getTableCellEditorComponent(), and for other rows
returns the "regular" cell editor component.

This is because JTable keeps track of cell editors for an
entire column. There's no way to say "use this editor for
row X but this editor for row Y" except by doing something
like this in getTableCellEditorComponent().

Depending on what you want, you may have to do something
similar with the cell renderers, too.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!