Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

java - JTable - drag column to increase width

I am new to Java and I am building a tool which uses a JTable. I wanted to expand the column and shrink accordingly, as the user drags the column. I am not exactly sure about the term used for this. This behavior could be noticed in Windows Explorer as attached. How could this be achieved? Proper direction would be appreciated!!

enter image description here

question from:https://stackoverflow.com/questions/66062243/jtable-drag-column-to-increase-width

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

JTable has the setAutoResizeMode, to resize all columns you can use AUTO_RESIZE_ALL_COLUMNS.

myTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...