我有一个 A 类和 B 类。 B 类从 A 类扩展而来。
在课堂上AI有这样的说法。
JCombobox namecombo;
JButton btnPrint = new JButton("Print");
btnPrint.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
CreateInvoiceTable op = new CreateInvoiceTable();
op.invoicetable();
insertingBillNoIntoDatabase();
String custname =namecombo.getSelectedItem().toString();
MessageFormat footer = new MessageFormat(custname);
MessageFormat header = new MessageFormat("SAHA TRADERS");
try {
table.print(JTable.PrintMode.FIT_WIDTH, header,footer);
} catch (PrinterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while(model_table.getRowCount()>0) {
model_table.removeRow(0);
}
itemcombo.setSelectedIndex(0);
}
});
我从组合框中选择了名称并点击了一个按钮(打印)来执行 B 类。
在 B 班。
public void invoicetable() {
String name = Invoice.namecombo.getSelectedItem().toString();
System.out.println(name);
}
public static void main(String[] args) {
CreateInvoiceTable a = new CreateInvoiceTable();
a.invoicetable();
}
}
现在当我打印它时。它只打印组合框的第一个值而不是
选定的值。
幕布斯6054654
相关分类