JTable change the row height dynamically [duplicate]
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();
i开发者_运维知识库f (table.getRowHeight(row) < height)
table.setRowHeight(row, height);
/* some more code */
return this;
}
}
Would this be the correct way to do this ? Thanks.
table.setRowHeight(...);
If you need more help post your SSCCE.
You simply call setRowHeight(row, height);
. For example:
JTable t = new JTable(5, 5);
t.setRowHeight(2, 30);
will set the 3rd row to 30 high.
Is your question more complicated? You haven't said much about the problem.
精彩评论