1

I want to render different swing components in the same JTable column. For example, I want to have few different comboboxes, jlabels and jcheckboxes in the same column. http://docs.oracle.com/javase/tutorial/uiswing/components/table.html provides information how to render only one type of combobox per column, however it is not enough.

How can I setup table cell renderer so that it would achieve this functionality?

Benas
  • 2,106
  • 2
  • 39
  • 66

1 Answers1

2

If you need to use different editors/renderers in the same column, you can follow the approach described in this answer and override JTable#getCellEditor() based on the cell (column and row intersection). JTable#getCellRenderer() can be overriden if needed as well.

In Concepts: Editors and Renderers is described the strategy followed by tables to get a renderer/editor so you can take advantage of it to solve your problem.

Community
  • 1
  • 1
dic19
  • 17,821
  • 6
  • 40
  • 69