nishihatapalmer / TreeTable

A Java Swing tree table using a standard JTable and any type of TreeNode or TreeModel.
BSD 3-Clause "New" or "Revised" License
6 stars 0 forks source link

Customize Cell Renderer based on the row rather than the column #11

Open alessiodiluzio opened 7 months ago

alessiodiluzio commented 7 months ago

Can you customize cell render based on the row ? For example consider the column number 2, i need some rows having a JComboBox as cell renderer and some others having a JLabel

nishihatapalmer commented 7 months ago

Hi - you can, but this is a function of a JTable, not the TreeTable model. The TreeTable is only concerned with the tree aspects of the tree table. One of the big advantages of this code is that you are basically working with a standard JTable.

JTable has a method you can override to customise which TableCellRenderer is used for rows or columns:

https://docs.oracle.com/javase/8/docs/api/javax/swing/JTable.html#getCellRenderer-int-int-

Also see this stack overflow article:

https://stackoverflow.com/questions/16407086/apply-a-tablecellrenderer-on-a-single-cell

Hope that helps!