Setting the height of a row in a JTable in java

前端 未结 4 1696
小蘑菇
小蘑菇 2021-02-19 13:04

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 n

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-19 14:05

    You can also add a tableModelListener?

    model.addTableModelListener(new TableModelListener() {
        @Override public void tableChanged(final TableModelEvent e) {
            EventQueue.invokeLater(new Runnable() {
                @Override public void run() {
                    table.setRowHeight(e.getFirstRow(), 15); //replace 15 with your own height
                }
            });
        }
    });
    

提交回复
热议问题