您好,我正在用 Java 制作 JTable,但遇到了奇怪的问题。我只能看到背景颜色。
这是负责创建的方法。
public void createCustomerList() {
table = new JTable();
tableModel = new DefaultTableModel();
tableModel.addColumn("Naam");
tableModel.addColumn("Achternaam");
tableModel.addColumn("Klant-ID");
table.setSize(954, 686);
table.setLocation(100, 78);
table.setBackground(Color.white);
table.setForeground(Color.black);
table.setGridColor(Color.black);
table.setRowHeight(30);
table.setFont(new Font("Tahoma", Font.PLAIN, 36));
JScrollPane scrollPane = new JScrollPane(table);
table.setModel(tableModel);
this.add(scrollPane);
this.add(table);
}
在我的构造函数中,我调用了这个方法。但我只得到背景颜色(将其更改为黑色或红色或其他颜色时)但我没有看到列和网格等。问题可能出在哪里?