gpt4 book ai didi

java - 如何更改下面 jtable 标题的字体

转载 作者:行者123 更新时间:2023-12-01 09:28:54 25 4
gpt4 key购买 nike

如何在jtable标题中设置字体粗体。

我的代码...

            table = new JTable();
model = new DefaultTableModel(){
public Class<?> getColumnClass(int column) {
switch (column) {
case 0:
return Boolean.class;
case 1:
return String.class;
case 2:
return String.class;
-----
----
case 19 :
return String.class;
}
}

public boolean isCellEditable(int row, int col) {
if (col > 0) {
return false;
} else
return (true);
}

};

model.addColumn(null);
String[] name = {"one","two","three",
"four","five",
"six","seven","eight","nine","ten","eleven","tweleve","thirteen","fourteen",
"fiveteen","sixteen","seventeen","eightteen","nineteen","twenty"};
for(int i=0;i<name.length;i++){
model.addColumn(name[i]);
}

DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment(SwingConstants.CENTER);
table.setDefaultRenderer(String.class, centerRenderer);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setAutoCreateRowSorter(true);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setModel(model);
TableColumn tc = table.getColumnModel().getColumn(0);
tc.setCellEditor(table.getDefaultEditor(Boolean.class));
tc.setCellRenderer(table.getDefaultRenderer(Boolean.class));
tc.setHeaderRenderer(new CheckBoxHeader11(new MyItemListener()));
tc.setMaxWidth(25);
tableScroll = new JScrollPane(table);

最佳答案

//设置列名的字体
table.getTableHeader().setFont(new Font("Ariel", Font.BOLD, 27));

关于java - 如何更改下面 jtable 标题的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39613234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com