java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
double qty1 = Double.parseDouble(txtnuts1.getText());
double qty2 = Double.parseDouble(txtnuts2.getText());
double qty3 = Double.parseDouble(txtnuts3.getText());
double qty4 = Double.parseDouble(txtnuts4.getText());
double qty5 = Double.parseDouble(txtnuts5.getText());
double nut1 = 2.50 * qty1;
double nut2 = 1.50 * qty2;
double nut3 = 3.00 * qty3;
double nut4 = 1.50 * qty4;
double nut5 = 1.50 * qty5;
double subtotal = nut1 + nut2 + nut3 + nut4 + nut5;
subtotal = Math.round(subtotal * 100.0) / 100.0;
lbltxtTotal7.setText("$" + String.format("%.2f", subtotal));
double taxes = subtotal * 0.13;
taxes = Math.round(taxes * 100.0) / 100.0;
lbltxtTotal6.setText("$" + String.format("%.2f", taxes));
double grandtotal = subtotal + taxes;
grandtotal = Math.round(grandtotal * 100.0) / 100.0;
lbltxtTotal8.setText("$" + String.format("%.2f", grandtotal));
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Please enter valid numeric quantities.");
}
}
});
// i think this is right code