📄 tablerowfile.java
字号:
package com.javasme.table;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
public class TableRowFile {
private JTable tableRowFile = new JTable();
TableModel tableRowFileModel;
public JTable setTableRowFile(int rowCount) {
// System.out.println("生成表头,行数为" + rowCount);
tableRowFileModel = null;
tableRowFileModel = new DefaultTableModel(rowCount, 1);
tableRowFile.setModel(tableRowFileModel);
tableRowFile.setBackground(new Color(236, 233, 216));
tableRowFile.setForeground(new Color(0, 0, 255));
for (int i = 0; i < rowCount; i++) {
// System.out.println("添加行号" + i);
tableRowFile.setValueAt(new Integer(i + 1), i, 0);
}
tableRowFile.getColumnModel().getColumn(0).setPreferredWidth(30);
tableRowFile.setPreferredScrollableViewportSize(new Dimension(tableRowFile.getColumnModel().getColumn(0).getPreferredWidth(), 0));
tableRowFile.setEnabled(false);
return tableRowFile;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -