Java Reference
In-Depth Information
Table 18-3. Auto-Resize Mode Constants
Modes
Description
AUTO_RESIZE_ALL_COLUMNS
Adjusts all column widths proportionally.
AUTO_RESIZE_LAST_COLUMN
Adjusts the rightmost column width only to give or
take space as required by the column currently being
altered. If no space is available within that column, then
resizing will work with the previous column until a
column with available space to consume is found.
AUTO_RESIZE_NEXT_COLUMN
If you're reducing the width of a neighboring column,
the neighboring column will grow to fill the unused
space. If you're increasing the width of a column, the
neighboring column will shrink.
AUTO_RESIZE_OFF
Turns off the user's ability to resize columns. The
columns can still be resized programmatically.
AUTO_RESIZE_SUBSEQUENT_COLUMNS
Adjusts the width by proportionally altering (default)
columns displayed to the right of the column being
changed.
Listing 18-1 demonstrates what effect each setting has when resizing table columns.
Listing 18-1. Resizable JTable
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
public class ResizeTable {
public static void main(String args[]) {
final Object rowData[][] = {
{"1", "one", "ichi - \u4E00", "un", "I"},
{"2", "two", "ni - \u4E8C", "deux", "II"},
{"3", "three", "san - \u4E09", "trois", "III"},
{"4", "four", "shi - \u56DB", "quatre", "IV"},
{"5", "five", "go - \u4E94", "cinq", "V"},
{"6", "six", "roku - \u516D", "treiza", "VI"},
{"7", "seven", "shichi - \u4E03", "sept", "VII"},
{"8", "eight", "hachi - \u516B", "huit", "VIII"},
{"9", "nine", "kyu - \u4E5D", "neur", "IX"},
{"10", "ten", "ju - \u5341", "dix", "X"}
};
 
Search WWH ::




Custom Search