Setting the height of a row in a JTable in java

Posted by Douglas Grealis on Stack Overflow See other posts from Stack Overflow or by Douglas Grealis
Published on 2013-04-06T17:10:24Z Indexed on 2013/11/08 9:55 UTC
Read the original article Hit count: 195

Filed under:
|
|
|

I have been searching for a solution to be able to increase the height of a row in a JTable. I have been using the setRowHeight(int int) method which compiles and runs OK, but no row[s] have been increased. When I use the getRowHeight(int) method of the row I set the height to, it does print out the size I increased the row to, so I'm not sure what is wrong. The code below is a rough illustration how I am trying to solve it.

My class extends JFrame.

String[] columnNames = {"Column 1", "Column 2", "Column 1 3"};

JTable table = new JTable(new DefaultTableModel(columnNames, people.size()));

DefaultTableModel model = (DefaultTableModel) table.getModel();

int count =1;
for(Person p: people)
{
    model.insertRow(count,(new Object[]{count, p.getName(), p.getAge()+"", 
    p.getNationality}));
    count++;
}

table.setRowHeight(1, 15);//Try set height to 15 (I've tried higher)

Can anyone tell me where I am going wrong? I am trying to increase the height of row 1 to 15 pixels?

© Stack Overflow or respective owner

Related posts about java

Related posts about swing