更改 table 中的预览字体?

Change preview font in table?

在我的程序中,我实现了一个 table,我最近发现了如何更改 table 的字体大小,所以这就是我所做的: 它将 table 中内容的字体设置为 20,但是在我使用 enter 或 select 另一个单元格确认输入之前,预览仍然是标准字体并且太小

table.setFont(new Font("Tahoma", Font.BOLD, 20));

预览也应该是一样的大小,这就是我想要做的。

您需要做的是像这样修改默认单元格编辑器:

Object dce = jTable1.getDefaultEditor(Object.class);
if(dce instanceof DefaultCellEditor) {
    Font font = new Font(jTable1.getFont().getName(), jTable1.getFont().getStyle(), 20);  // 20 is your desired font size
    ((DefaultCellEditor) dce).getComponent().setFont(font);
}

这个概念是由@Redwine 从这个 SO Answer 中检索到的。