JTable table = new JTable(data, columnNames); TableColumnModel columnModel = table.getColumnModel(); TableColumn firstColumn = columnModel.getColumn(0); firstColumn.setMinWidth(100); firstColumn.setMaxWidth(100);
String[] columnOrder = {"Name", "Age", "Gender", "City"}; TableColumnModel columnModel = table.getColumnModel(); for (int i = 0; i < columnOrder.length; i++) { int columnIndex = table.getColumn(columnOrder[i]).getModelIndex(); columnModel.moveColumn(columnIndex, i); }The package library for javax.swing is part of the Java SE Desktop Development Kit. It contains classes for building desktop applications, including GUI components like JTable.