我正在實施一個咖啡店選單,但在單選按鈕和微調器方面遇到了一些麻煩。
如何計算多個單選按鈕的總價,每個單選按鈕都有小計價格?因為現在,我只能計算一種產品的總數。
我應該添加一個單選按鈕組或類似的東西嗎?
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
double Total = 0.0;
if(rbCappucino.isSelected()){
String Cappucino = chboxCappucino.getValue().toString();
int boom1 = Integer.parseInt(Cappucino);
Total = boom1 * 1.0;
}
else if(rbAmericano.isSelected()){
String Americano = chboxAmericano.getValue().toString();
int boom2 = Integer.parseInt(Americano);
Total = boom2 * 1.50;
}
else if(rbLatte.isSelected()){
String Latte = chboxLatte.getValue().toString();
int boom3 = Integer.parseInt(Latte);
Total = boom3 * 2.50;
}
totalText.setText(Double.toString(Total));
}

uj5u.com熱心網友回復:
本javax.swing.JRadioButton是為了準確地選擇一個選項,以便在你的情況,你應該增加javax.swing.JCheckBox而不是
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/354597.html
標籤:爪哇 摇摆 框架 jradiobutton 微调器
