Auto resize the widths of JTable's columns dynamically

前端 未结 3 457
隐瞒了意图╮
隐瞒了意图╮ 2020-12-11 03:07

I have a JTable with 3 columns:

- No. #
- Name
- PhoneNumber

I want to make specific width for each column as follows:

3条回答
  •  轮回少年
    2020-12-11 03:55

    Use the addRow(...) method of the DefaultTableModel to add data to the table dynamically.

    Update:

    To adjust the width of a visible column I think you need to use:

    tableColumn.setWidth(...);
    

提交回复
热议问题