JTable in JScrollPane fixed size with resizeable JFrame?

前端 未结 1 472
鱼传尺愫
鱼传尺愫 2021-01-27 05:57

I have a JTable inside of a JScrollPane. I want to get the columns to stay fixed when I resize it. The rows stay the same size, and there is a scrollba

相关标签:
1条回答
  • 2021-01-27 06:16

    Set the table's auto resize mode to "off"

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    

    Take a look at JTable#setAutoResizeMode for more details.

    Update

    I should mention, this will mean you will become responsible for determine the size of each column.

    Take a look at How to use tables and Setting and Changing Column Widths

    0 讨论(0)
提交回复
热议问题