Mega Code Archive

 
Categories / Java Tutorial / Swing
 

When the width of a column is changed, the width of the right-most column is changed

import javax.swing.JTable; public class Main {   public static void main(String[] argv) throws Exception {     Object[][] cellData = { { "1-1", "1-2" }, { "2-1", "2-2" } };     String[] columnNames = { "col1", "col2" };     JTable table = new JTable(cellData, columnNames);     table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);   } }