Answer the question
In order to leave comments, you need to log in
How to properly set column widths in Swing?
Good day.
I am studying an example of a table in Swing, and the following question arose:
The table is presented as a DefaultTableModel object, however, an attempt to set the width of the columns:
did not lead to success, and the import required for these methods:
infoTable.getColumn(1).setPreferredWidth(150);
import javax.swing.table.TableModel;
import javax.swing.table.TableColumnModel;
Answer the question
In order to leave comments, you need to log in
TOB BOT , thank you very much.
I finally found a working version - precisely through the mvc model.
infoTableModel.getColumnModel().getColumn(0).setPreferredWidth(150);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question