e949. packing a jtable component.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 22 行
TXT
22 行
This example demonstrates how to adjust the preferred size of a JTable to be just large enough to accommodate the preferred size of all cells.
int rows = 10;
int cols = 5;
JTable table = new JTable(rows, cols) {
// Override this method so that it returns the preferred
// size of the JTable instead of the default fixed size
public Dimension getPreferredScrollableViewportSize() {
return getPreferredSize();
}
};
// Allow columns to be resized
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// Add data...
// These packing methods are defined in e950 Packing a Column of a JTable Component
// and e913 Setting the Height of a Row in a JTable Component
packColumns(table, 2);
packRows(table, 0);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?