When the width of a column is changed, the width of the right-most column is changed : Table Column « Swing JFC « Java






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);
  }
}

   
  








Related examples in the same category

1.Combine TableModel and ColumModelCombine TableModel and ColumModel
2.JTable with a custom column modelJTable with a custom column model
3.A row header column with the TableColumnModelA row header column with the TableColumnModel
4.Install Table Column to TableColumnModelInstall Table Column to TableColumnModel
5.Swing Table Column ToolTip SampleSwing Table Column ToolTip Sample
6.Table ColumnModel and TableColumnModelListenerTable ColumnModel and TableColumnModelListener
7.Table header: Label Header with iconTable header: Label Header with icon
8.Table Headerless SampleTable Headerless Sample
9.Multiline table headerMultiline table header
10.Row Number Table Header
11.Frozen Column Table Header
12.Packing a Column of a JTable Component according to the header text
13.Packing a Column of a JTable Component according to the row data
14.Set column width based on cell renderer
15.Set table column auto-resize off
16.Get the columns from TableColumnModel in the order that they appear in the view
17.Get column count
18.Returns the TableColumn associated with the specified column index in the model
19.Setting the Width of a Column in a JTable Component
20.Disable auto resizing, Set the first visible column to 100 pixels wide
21.Setting the Column Resize Mode of a JTable Component: Disable auto resizing
22.When the width of a column is changed, all columns to the right are resized
23.When the width of a column is changed, only the columns to the left and right of the margin change
24.When the width of a column is changed, the widths of all columns are changed
25.Locking the Width of a Column in a JTable Component
26.This program demonstrates how to work with rows and columns in a table.