Java by API/javax.swing/JTableHeader — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 20:43, 31 мая 2010
JTableHeader: resizeAndRepaint()
<source lang="java">
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(); }
}
</source>
JTableHeader: setReorderingAllowed(boolean reorderingAllowed)
<source lang="java">
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); }
}
</source>
JTableHeader: setResizingAllowed(boolean resizingAllowed)
<source lang="java">
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); }
}
</source>