Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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();
      if (table.getRowHeight(row) < height)
          table.setRowHeight(row, height);

      /* some more code */

      return this;
  }

}

Would this be the correct way to do this ? Thanks.

like image 537
kohlerfc Avatar asked Aug 11 '10 01:08

kohlerfc


1 Answers

table.setRowHeight(...);

If you need more help post your SSCCE.

like image 126
camickr Avatar answered Oct 24 '22 16:10

camickr