Java by API/javax.swing/JTableHeader
Версия от 17:43, 31 мая 2010; (обсуждение)
JTableHeader: resizeAndRepaint()
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class Main {
public static void main(String[] argv) throws Exception {
DefaultTableModel model = new DefaultTableModel();
JTable table = new JTable(model);
model.addColumn("Col1");
model.addColumn("Col2");
table.getColumnModel().getColumn(0).setHeaderValue("New Name");
table.getTableHeader().resizeAndRepaint();
}
}
JTableHeader: setReorderingAllowed(boolean reorderingAllowed)
import javax.swing.JTable;
public class Main {
public static void main(String[] argv) throws Exception {
int rows = 3;
int cols = 3;
JTable table = new JTable(rows, cols);
table.getTableHeader().setReorderingAllowed(false);
table.moveColumn(table.getColumnCount() - 1, 0);
}
}
JTableHeader: setResizingAllowed(boolean resizingAllowed)
import javax.swing.JTable;
public class Main {
public static void main(String[] argv) throws Exception {
int rows = 3;
int cols = 3;
JTable table = new JTable(rows, cols);
table.getTableHeader().setResizingAllowed(false);
}
}