This question already has an answer here:
- Auto adjust the height of rows in a JTable 3 answers
i am having trouble changing the height of the my rows dynamically, is there a method i need to overload?
--Edit--
Sorry for the short post it was my first ....My problems was really to do with changing the row height depending on the content. So what i have done so far is made a inner class that implements TabelCellRenderer.
This is what i am doing at the moment for my row height calculations.
private static class TextAreaRenderer extends JTextPane implements TableCellRenderer
{
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected,
boolean hasFocus, int row,
int column)
{
/* Setup Code here */
this.setText(((String)value).getEntityName());
int height = new Double(this.getPreferredSize().getHeight()).intValue();
if (table.getRowHeight(row) < height)
table.setRowHeight(row, height);
/* some more code */
return this;
}
}
Would this be the correct way to do this ? Thanks.