8375573: JTable ignores setPreferredWidth during initial layout when AUTO_RESIZE_LAST_COLUMN is enabled

This commit is contained in:
Prasanta Sadhukhan 2026-01-19 02:10:33 +00:00
parent 9a42fdbac4
commit 9b6ac608ad

View File

@ -3195,6 +3195,11 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
public void doLayout() {
boolean prefWidthSet = false;
TableColumn resizingColumn = getResizingColumn();
// doLayout is called for both pack and show
// so if initial preferred width is set by user then
// it needs to be honoured even if resizingColumn
// is set to last column on account of
// AUTO_RESIZE_LAST_COLUMN autoResizeMode
for (int i = 0; i < columnModel.getColumnCount(); i++) {
if (columnModel.getColumn(i).getPreferredWidth() != 75
&& columnModel.getColumn(i).getWidth() == 75) {