Listing pada Combo Box
private void comboActionPerformed(java.awt.event.ActionEvent evt) {
if(combo.getSelectedItem().equals("MINYAK GORENG"))
{
tmerk.setText("Filma");
tharga.setText("20000");
}
else if(combo.getSelectedItem().equals("MIE INSTAN"))
{
tmerk.setText("Indomie");
tharga.setText("15000");
}
else
{
tmerk.setText("Java Latte Grande");
tharga.setText("10000");
}
tqty.requestFocus();
}
Listing pada JTextField QTY ketika di Klik maka Total Bayar akan Muncul
private void tqtyActionPerformed(java.awt.event.ActionEvent evt) {
double a,b,c;
String hasil;
a=Double.parseDouble(tharga.getText());
b=Double.parseDouble(tqty.getText());
c=a*b;
hasil=String.valueOf(c);
tbayar.setText(hasil);
tubay.requestFocus();
}
Listing Bersih
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
combo.setSelectedIndex(0);
tharga.setText("");
tqty.setText("");
tubay.setText("");
tukem.setText("");
tbayar.setText("");
tmerk.setText("");
}
Listing Tombol Keluar
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int x;
x=JOptionPane.showConfirmDialog(null,"Anda Ingin Keluar","Konfirmasi",JOptionPane.YES_NO_OPTION);
if(x==JOptionPane.YES_NO_OPTION);
dispose();
}
Jika sobat-sobat melakukan coding dengan benar maka Outputnya seperti ini :
Tetap belajar dan salam sukses...
By Onayandra
No comments:
Post a Comment