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

Using Comboboxes with JTable where first row displaying comboxes.

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 824
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check this

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


Enjoy
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic