Program Kasir
1. Deskripsi
Program ini dibuat agar mempermudah kasir dalam melakukan transaksi. Kasir hanya perlu memasukkan qty pesanan yang diminta customer. Dalam program ini pula menu dan harga sudah tertera. Jadi, kasir dapat menjalankan program ini untuk mengetahui jumlah yang harus dibayar oleh customer
2. Komponen & Variabel
3. Rumus
total = total * harga
4. Flowchart
5. Source Code
public class baraya extends javax.swing.JFrame {
public baraya() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jCheckBox1SOTO = new javax.swing.JCheckBox();
jCheckBox2MIE_AYAM = new javax.swing.JCheckBox();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jCheckBox3NASI_GORENG = new javax.swing.JCheckBox();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
SOTO = new java.awt.TextField();
MIE_AYAM = new java.awt.TextField();
NASI_GORENG = new java.awt.TextField();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
OK = new javax.swing.JButton();
TOTAL = new java.awt.TextField();
jLabel11 = new javax.swing.JLabel();
HAPUS = new javax.swing.JButton();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jLabel10.setText("jLabel10");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel1.setText("BARAYA KANTIN");
jCheckBox1SOTO.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox1SOTOActionPerformed(evt);
}
});
jCheckBox2MIE_AYAM.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox2MIE_AYAMActionPerformed(evt);
}
});
jLabel2.setText("MENU");
jLabel3.setText("HARGA");
jCheckBox3NASI_GORENG.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox3NASI_GORENGActionPerformed(evt);
}
});
jLabel4.setText("Rp 12.000");
jLabel5.setText("Rp 11.000");
jLabel6.setText("Rp 10.000");
SOTO.setEditable(false);
SOTO.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SOTOActionPerformed(evt);
}
});
MIE_AYAM.setEditable(false);
MIE_AYAM.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MIE_AYAMActionPerformed(evt);
}
});
NASI_GORENG.setEditable(false);
NASI_GORENG.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NASI_GORENGActionPerformed(evt);
}
});
jLabel7.setText("SOTO");
jLabel8.setText("MIE AYAM");
jLabel9.setText("NASI GORENG");
OK.setText("OK");
OK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OKActionPerformed(evt);
}
});
TOTAL.setEditable(false);
TOTAL.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TOTALActionPerformed(evt);
}
});
jLabel11.setText("TOTAL Rp");
HAPUS.setText("HAPUS");
HAPUS.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HAPUSActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(67, 67, 67)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox2MIE_AYAM)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel8))
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox3NASI_GORENG)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel9))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox1SOTO)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel7))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(SOTO, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(MIE_AYAM, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(NASI_GORENG, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(58, 58, 58)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(HAPUS)
.addComponent(OK, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(TOTAL, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(270, 270, 270))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(71, 71, 71)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox1SOTO)
.addGap(12, 12, 12))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCheckBox2MIE_AYAM)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addComponent(MIE_AYAM, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jCheckBox3NASI_GORENG))
.addComponent(NASI_GORENG, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel11)
.addComponent(TOTAL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(SOTO, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(OK))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(HAPUS)))
.addContainerGap(68, Short.MAX_VALUE))
);
TOTAL.getAccessibleContext().setAccessibleName("");
pack();
}// </editor-fold>
private void jCheckBox2MIE_AYAMActionPerformed(java.awt.event.ActionEvent evt) {
if (jCheckBox2MIE_AYAM.isSelected() == true){
MIE_AYAM.setEditable(true);
}else {
MIE_AYAM.setEditable (false);
MIE_AYAM.setText("");
}// TODO add your handling code here:
}
private void jCheckBox3NASI_GORENGActionPerformed(java.awt.event.ActionEvent evt) {
if (jCheckBox3NASI_GORENG.isSelected() == true){
NASI_GORENG.setEditable(true);
}else {
NASI_GORENG.setEditable (false);
NASI_GORENG.setText("");
}// TODO add your handling code here:
}
private void SOTOActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void MIE_AYAMActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void NASI_GORENGActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jCheckBox1SOTOActionPerformed(java.awt.event.ActionEvent evt) {
if (jCheckBox1SOTO.isSelected() == true){
SOTO.setEditable(true);
}else {
SOTO.setEditable (false);
SOTO.setText("");
}
// TODO add your handling code here:
}
private void OKActionPerformed(java.awt.event.ActionEvent evt) {
int total = 0;
if (jCheckBox1SOTO.isSelected()){
String S = SOTO.getText();
int jumlahS = Integer.parseInt(S);
int hargaS = jumlahS * 12000;
total = total + hargaS;
}
if (jCheckBox2MIE_AYAM.isSelected()){
String MA = MIE_AYAM.getText();
int jumlahMA = Integer.parseInt(MA);
int hargaMA = jumlahMA * 11000;
total = total + hargaMA;
}
if (jCheckBox3NASI_GORENG.isSelected()){
String NS = NASI_GORENG.getText();
int jumlahNS = Integer.parseInt(NS);
int hargaNS = jumlahNS * 10000;
total = total + hargaNS;
}
TOTAL.setText(""+total);
// TODO add your handling code here:
}
private void TOTALActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void HAPUSActionPerformed(java.awt.event.ActionEvent evt) {
SOTO.setEditable(false);
SOTO.setText("");
MIE_AYAM.setEditable(false);
MIE_AYAM.setText("");
NASI_GORENG.setEditable(false);
NASI_GORENG.setText("");
TOTAL.setText("");
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(baraya.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(baraya.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(baraya.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(baraya.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new baraya().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton HAPUS;
private java.awt.TextField MIE_AYAM;
private java.awt.TextField NASI_GORENG;
private javax.swing.JButton OK;
private java.awt.TextField SOTO;
private java.awt.TextField TOTAL;
private javax.swing.JCheckBox jCheckBox1SOTO;
private javax.swing.JCheckBox jCheckBox2MIE_AYAM;
private javax.swing.JCheckBox jCheckBox3NASI_GORENG;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}
Program ini dibuat agar mempermudah kasir dalam melakukan transaksi. Kasir hanya perlu memasukkan qty pesanan yang diminta customer. Dalam program ini pula menu dan harga sudah tertera. Jadi, kasir dapat menjalankan program ini untuk mengetahui jumlah yang harus dibayar oleh customer
2. Komponen & Variabel
- SOTO
- NASI_GORENG
- MIE_AYAM
- ST
- NS
- MA
- TOTAL
- OK
3. Rumus
total = total * harga
4. Flowchart
5. Source Code
public class baraya extends javax.swing.JFrame {
public baraya() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jCheckBox1SOTO = new javax.swing.JCheckBox();
jCheckBox2MIE_AYAM = new javax.swing.JCheckBox();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jCheckBox3NASI_GORENG = new javax.swing.JCheckBox();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
SOTO = new java.awt.TextField();
MIE_AYAM = new java.awt.TextField();
NASI_GORENG = new java.awt.TextField();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
OK = new javax.swing.JButton();
TOTAL = new java.awt.TextField();
jLabel11 = new javax.swing.JLabel();
HAPUS = new javax.swing.JButton();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jLabel10.setText("jLabel10");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel1.setText("BARAYA KANTIN");
jCheckBox1SOTO.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox1SOTOActionPerformed(evt);
}
});
jCheckBox2MIE_AYAM.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox2MIE_AYAMActionPerformed(evt);
}
});
jLabel2.setText("MENU");
jLabel3.setText("HARGA");
jCheckBox3NASI_GORENG.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBox3NASI_GORENGActionPerformed(evt);
}
});
jLabel4.setText("Rp 12.000");
jLabel5.setText("Rp 11.000");
jLabel6.setText("Rp 10.000");
SOTO.setEditable(false);
SOTO.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SOTOActionPerformed(evt);
}
});
MIE_AYAM.setEditable(false);
MIE_AYAM.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MIE_AYAMActionPerformed(evt);
}
});
NASI_GORENG.setEditable(false);
NASI_GORENG.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NASI_GORENGActionPerformed(evt);
}
});
jLabel7.setText("SOTO");
jLabel8.setText("MIE AYAM");
jLabel9.setText("NASI GORENG");
OK.setText("OK");
OK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
OKActionPerformed(evt);
}
});
TOTAL.setEditable(false);
TOTAL.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TOTALActionPerformed(evt);
}
});
jLabel11.setText("TOTAL Rp");
HAPUS.setText("HAPUS");
HAPUS.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HAPUSActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(67, 67, 67)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox2MIE_AYAM)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel8))
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox3NASI_GORENG)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel9))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox1SOTO)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel7))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(SOTO, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(MIE_AYAM, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(NASI_GORENG, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(58, 58, 58)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(HAPUS)
.addComponent(OK, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(TOTAL, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(270, 270, 270))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(71, 71, 71)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox1SOTO)
.addGap(12, 12, 12))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCheckBox2MIE_AYAM)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addComponent(MIE_AYAM, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jCheckBox3NASI_GORENG))
.addComponent(NASI_GORENG, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel11)
.addComponent(TOTAL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(SOTO, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(OK))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(HAPUS)))
.addContainerGap(68, Short.MAX_VALUE))
);
TOTAL.getAccessibleContext().setAccessibleName("");
pack();
}// </editor-fold>
private void jCheckBox2MIE_AYAMActionPerformed(java.awt.event.ActionEvent evt) {
if (jCheckBox2MIE_AYAM.isSelected() == true){
MIE_AYAM.setEditable(true);
}else {
MIE_AYAM.setEditable (false);
MIE_AYAM.setText("");
}// TODO add your handling code here:
}
private void jCheckBox3NASI_GORENGActionPerformed(java.awt.event.ActionEvent evt) {
if (jCheckBox3NASI_GORENG.isSelected() == true){
NASI_GORENG.setEditable(true);
}else {
NASI_GORENG.setEditable (false);
NASI_GORENG.setText("");
}// TODO add your handling code here:
}
private void SOTOActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void MIE_AYAMActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void NASI_GORENGActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jCheckBox1SOTOActionPerformed(java.awt.event.ActionEvent evt) {
if (jCheckBox1SOTO.isSelected() == true){
SOTO.setEditable(true);
}else {
SOTO.setEditable (false);
SOTO.setText("");
}
// TODO add your handling code here:
}
private void OKActionPerformed(java.awt.event.ActionEvent evt) {
int total = 0;
if (jCheckBox1SOTO.isSelected()){
String S = SOTO.getText();
int jumlahS = Integer.parseInt(S);
int hargaS = jumlahS * 12000;
total = total + hargaS;
}
if (jCheckBox2MIE_AYAM.isSelected()){
String MA = MIE_AYAM.getText();
int jumlahMA = Integer.parseInt(MA);
int hargaMA = jumlahMA * 11000;
total = total + hargaMA;
}
if (jCheckBox3NASI_GORENG.isSelected()){
String NS = NASI_GORENG.getText();
int jumlahNS = Integer.parseInt(NS);
int hargaNS = jumlahNS * 10000;
total = total + hargaNS;
}
TOTAL.setText(""+total);
// TODO add your handling code here:
}
private void TOTALActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void HAPUSActionPerformed(java.awt.event.ActionEvent evt) {
SOTO.setEditable(false);
SOTO.setText("");
MIE_AYAM.setEditable(false);
MIE_AYAM.setText("");
NASI_GORENG.setEditable(false);
NASI_GORENG.setText("");
TOTAL.setText("");
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(baraya.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(baraya.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(baraya.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(baraya.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new baraya().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton HAPUS;
private java.awt.TextField MIE_AYAM;
private java.awt.TextField NASI_GORENG;
private javax.swing.JButton OK;
private java.awt.TextField SOTO;
private java.awt.TextField TOTAL;
private javax.swing.JCheckBox jCheckBox1SOTO;
private javax.swing.JCheckBox jCheckBox2MIE_AYAM;
private javax.swing.JCheckBox jCheckBox3NASI_GORENG;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}
6. Hasil Run
Komentar
Posting Komentar