Im公司为一家小店经营一个方案。 当我点击“报告”时,它必须显示一个表象:
Column names "A", "B"..."N", must be the names of the employees. But I can t figure out how. Here is my code:
public void Inform()
{
String[] employee;
String[] product[];
this.setLayout(null);
Inform=new JTable(nulo, employee.length);
model = new DefaultTableModel() {
private static final long serialVersionUID = 1L;
@Override
public int getColumnCount() {
return 1;
}
@Override
public boolean isCellEditable(int row, int col) {
return false;
}
@Override
public int getRowCount() {
return Inform.getRowCount();
}
};
headerTable = new JTable(model);
for (int i = 0; i < Inform.getRowCount(); i++)
headerTable.setValueAt(product[i], i, 0);
headerTable.setShowGrid(false);
headerTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
headerTable.setPreferredScrollableViewportSize(new Dimension(50, 0));
headerTable.getColumnModel().getColumn(0).setPreferredWidth(50);
scrollPane = new JScrollPane(Inform);
scrollPane.setRowHeaderView(headerTable);
scrollPane.setBounds(5,5,500,500);
scrollPane.setEnabled(false);
this.add(scrollPane);
}
雇员和产品数量取决于加入人数。 努洛是有多少产品可以出售。