private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)
{
try {
Connection c = DBconnection.conn();
PreparedStatement ps = c.prepareStatement("SELECT * from menu where items=?");
ps.setString(1, (String) jComboBox2.getSelectedItem());
ResultSet rs = ps.executeQuery();
DefaultTableModel tbn = (DefaultTableModel) jTable1.getModel();
Vector v = new Vector<>();
v.add(jComboBox2.getSelectedItem());
v.add(qty.getText());
此行之后,我需要添加类型为double的价格,我正在从数据库中获取价格。我需要知道该怎么做。请有人帮忙
tbn.addRow(v);
我在这里计算总数。
double total = 0;
for(int i=0; i<jTable1.getRowCount(); i++)
{
double amount = Double.parseDouble(String.valueOf(jTable1.getValueAt(i, 2)));
jTable1.getValueAt(i,1));
total+=amount;
}
Ltot.setText(String.valueOf(total));
} catch (Exception ex) {
Logger.getLogger(pos.class.getName()).log(Level.SEVERE, null, ex);
}
} *emphasized text*