我将 aJTable
放在 a 中JPanel
,但是当我显示时,我看到的是表格内容,但看不到列名。
public class Neww extends JPanel
{
Connection conn = null;
Statement st;
DefaultTableModel model = new DefaultTableModel(new Object[][] {
{ " ", " " },
{ " ", " " },
{ " ", " " },
{ " ", " " },
{ " ", " " },
{ " ", " " }
}, new Object[] {
"ItemName",
"No of items"
});
JTable table = new JTable(model);
TableColumn ItemName = table.getColumnModel().getColumn(0);
JComboBox comboBox = new JComboBox();
Neww()
{
this.setLayout(new FlowLayout(FlowLayout.CENTER));
this.add(table);
comboBox.addItem("Spoon");
comboBox.addItem("Plate");
comboBox.addItem("Mixer");
comboBox.addItem("Glass");
ItemName.setCellEditor(new DefaultCellEditor(comboBox));
}
}