本文整理汇总了Java中javax.swing.JTable.setGridColor方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setGridColor方法的具体用法?Java JTable.setGridColor怎么用?Java JTable.setGridColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setGridColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import javax.swing.JTable; //导入方法依赖的package包/类
public void show(int dif) {
ArrayList<record> rec = new ArrayList<record>();
String content = FileHelper.readFromFile("ranking.ini");
if (content != null ) {
if(!content.equals("")) {
String[] sp = content.split(",");
for (int i = 0; i < sp.length; i = i + 3) {
if (dif == Integer.parseInt(sp[i])) {
rec.add(new record(sp[i + 2], Integer.parseInt(sp[i + 1])));
}
}
}
Collections.sort(rec);
rank = new Object[rec.size()][COL];
for (int i = 0; i < rec.size(); i++) {
record temp = rec.get(i);
rank[i][0] = i + 1;
rank[i][2] = temp.date;
rank[i][1] = temp.score;
}
table = new JTable(rank, title);
centerPanel.removeAll();
centerPanel.setLayout(new BorderLayout());
centerPanel.add(new JScrollPane(table), BorderLayout.CENTER);
DefaultTableCellRenderer r = new DefaultTableCellRenderer();
r.setHorizontalAlignment(JLabel.CENTER);
table.setDefaultRenderer(Object.class, r);
table.setRowHeight(20);
table.setFont(new Font("微软雅黑", 0, 14));
table.setGridColor(Color.BLUE);
table.setSize(centerPanel.getWidth(), centerPanel.getHeight());
table.setRowSelectionAllowed(false);
}
setVisible(true);
}
示例2: checkTableGridLines
import javax.swing.JTable; //导入方法依赖的package包/类
private static void checkTableGridLines() {
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() {
return 10;
}
public int getRowCount() {
return 10;
}
public Object getValueAt(int row, int col) {
return " ";
}
};
DefaultTableCellRenderer r = new DefaultTableCellRenderer();
r.setOpaque(true);
r.setBackground(CELL_RENDERER_BACKGROUND_COLOR);
JTable table = new JTable(dataModel);
table.setSize(WIDTH, HEIGHT);
table.setDefaultRenderer(Object.class, r);
table.setGridColor(GRID_COLOR);
table.setShowGrid(true);
table.setShowHorizontalLines(true);
table.setShowVerticalLines(true);
table.setBackground(TABLE_BACKGROUND_COLOR);
checkTableGridLines(table);
}