1. Penjelasan Program Pada kesempatan kali ini saya akan menjelaskan bagaimana cara membuat aplikasi "Program Kasir Sederhana". Disini saya telah menbuat sebuah program kasir sederhana dengan menggunakan bahasa java. Fungsi program ini adalah sebagai mesin hitung otomastis untuk mempermudah kita untuk menghitung total pesanan yang akan dibayarkan oleh pelanggan.
2. FlowChart
3. Screenshoot Aplikasi
*jendela login
*hasil ketika salah password
*program akan terbuka jika login benar
*tampilan ketika menjalankan program
4. Source Code
- Coding Form Login
/*
* To change this license header, choose
License Headers in Project Properties.
* To change this template file, choose Tools |
Templates
* and open the template in the editor.
*/
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author rifa
*/
public class Login
extends javax.swing.JFrame {
/**
* Creates new form Login
*/
public Login() {
initComponents();
}
/**
* This method is called from within the
constructor to initialize the form.
* WARNING: Do NOT modify this code. The
content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold
defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
btnlogin = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
formuser = new
javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
formpass = new
javax.swing.JPasswordField();
jPanel3 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
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)
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(255,
0, 51));
getContentPane().setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());
btnlogin.setBackground(new java.awt.Color(255,
153, 153));
btnlogin.setFont(new
java.awt.Font("Tahoma", 1, 11)); // NOI18N
btnlogin.setForeground(new
java.awt.Color(255, 255, 255));
btnlogin.setText("LOGIN");
btnlogin.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnloginActionPerformed(evt);
}
});
getContentPane().add(btnlogin, new
org.netbeans.lib.awtextra.AbsoluteConstraints(190, 230, -1, -1));
jPanel2.setBackground(new
java.awt.Color(51, 51, 51));
jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1,
1));
jLabel2.setFont(new
java.awt.Font("Tahoma", 0, 12)); // NOI18N
jLabel2.setForeground(new
java.awt.Color(255, 255, 255));
jLabel2.setText("User");
jLabel3.setFont(new
java.awt.Font("Tahoma", 0, 12)); // NOI18N
jLabel3.setForeground(new
java.awt.Color(255, 255, 255));
jLabel3.setText("Password");
javax.swing.GroupLayout jPanel2Layout =
new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23,
Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(formuser)
.addComponent(formpass,
javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE))
.addGap(46, 46, 46))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(formuser,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(32, 32, 32)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(formpass,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(56,
Short.MAX_VALUE))
);
getContentPane().add(jPanel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(87, 53, -1, -1));
jPanel3.setBackground(new
java.awt.Color(255, 0, 51));
jPanel4.setBackground(new
java.awt.Color(255, 153, 153));
jLabel1.setFont(new
java.awt.Font("Gabriola", 1, 18)); // NOI18N
jLabel1.setForeground(new
java.awt.Color(255, 255, 255));
jLabel1.setText("LOGIN");
javax.swing.GroupLayout jPanel4Layout =
new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel4Layout.createSequentialGroup()
.addContainerGap(184,
Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(181, 181, 181))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel4Layout.createSequentialGroup()
.addGap(0, 11, Short.MAX_VALUE)
.addComponent(jLabel1))
);
javax.swing.GroupLayout jPanel3Layout =
new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel4,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jPanel4,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 278, Short.MAX_VALUE))
);
getContentPane().add(jPanel3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 410, 320));
pack();
}// </editor-fold>
private void
btnloginActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Connection conn = null;
try {
conn = new koneksi().koneksiDB();
} catch (SQLException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE,
null, ex);
}
String sql = "select * from login
where Username=? and Password=?";
try {
PreparedStatement ps =
(PreparedStatement) conn.prepareStatement(sql);
ps.setString(1,
formuser.getText());
ps.setString(2,
formpass.getText());
ResultSet rs = ps.executeQuery();
if(rs.next()){
this.dispose();
ulangcoba Ulangcoba=new
ulangcoba();
Ulangcoba.show();
} else{
JOptionPane.showMessageDialog(null, "Maaf Username dan Password
Invalid");
}
} catch (Exception e) {
}
}
/**
* @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(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Login.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 Login().setVisible(true);
}
});
}
// Variables declaration - do not
modify
private javax.swing.JButton btnlogin;
private javax.swing.JPasswordField
formpass;
private javax.swing.JTextField formuser;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
// End of variables declaration
}
- Coding untuk Program
import javax.swing.JOptionPane;
/*
* To change this license header, choose
License Headers in Project Properties.
* To change this template file, choose Tools |
Templates
* and open the template in the editor.
*/
/**
*
* @author rifa
*/
public class ulangcoba
extends javax.swing.JFrame {
private Object box166;
/**
* Creates new form ulangcoba
*/
public ulangcoba() {
initComponents();
}
/**
* This method is called from within the
constructor to initialize the form.
* WARNING: Do NOT modify this code. The
content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold
defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
btnayam1 = new
javax.swing.JRadioButton();
btnayam2 = new
javax.swing.JRadioButton();
btnayam3 = new
javax.swing.JRadioButton();
btnayam4 = new
javax.swing.JRadioButton();
btnminum1 = new
javax.swing.JRadioButton();
btnminum2 = new
javax.swing.JRadioButton();
btnminum3 = new
javax.swing.JRadioButton();
btnhitung = new javax.swing.JButton();
btnhitung1 = new javax.swing.JButton();
btnkeluar = new javax.swing.JButton();
x1 = new javax.swing.JLabel();
x2 = new javax.swing.JLabel();
x3 = new javax.swing.JLabel();
x4 = new javax.swing.JLabel();
x5 = new javax.swing.JLabel();
x6 = new javax.swing.JLabel();
x7 = new javax.swing.JLabel();
jmlh1 = new javax.swing.JTextField();
jmlh2 = new javax.swing.JTextField();
jmlh3 = new javax.swing.JTextField();
jmlh4 = new javax.swing.JTextField();
jmlh5 = new javax.swing.JTextField();
jmlh6 = new javax.swing.JTextField();
jmlhtotal = new
javax.swing.JTextField();
lblayam1 = new
javax.swing.JTextField();
lblayam2 = new
javax.swing.JTextField();
lblayam3 = new
javax.swing.JTextField();
lblayam4 = new
javax.swing.JTextField();
lblminum1 = new
javax.swing.JTextField();
lblminum2 = new
javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
lblminum3 = new
javax.swing.JTextField();
jmlh7 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new
java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel1.setBackground(new
java.awt.Color(204, 204, 255));
jPanel1.setLayout(new
org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel2.setBackground(new
java.awt.Color(204, 0, 51));
jPanel2.setBorder(javax.swing.BorderFactory.createMatteBorder(1,
1, 1, 1, new java.awt.Color(204, 0, 51)));
jLabel1.setFont(new
java.awt.Font("Coneria Script Demo", 0, 18)); // NOI18N
jLabel1.setForeground(new
java.awt.Color(255, 255, 255));
jLabel1.setText("Kasir");
javax.swing.GroupLayout jPanel2Layout =
new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(183, 183, 183)
.addComponent(jLabel1))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1.add(jPanel2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 420, -1));
btnayam1.setBackground(new
java.awt.Color(0, 0, 0));
btnayam1.setFont(new
java.awt.Font("Giddyup Std", 0, 18)); // NOI18N
btnayam1.setForeground(new
java.awt.Color(255, 255, 255));
btnayam1.setText("Ayam
Bakar");
btnayam1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnayam1ActionPerformed(evt);
}
});
jPanel1.add(btnayam1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(28, 81, -1, -1));
btnayam2.setBackground(new
java.awt.Color(0, 0, 0));
btnayam2.setFont(new
java.awt.Font("Giddyup Std", 0, 18)); // NOI18N
btnayam2.setForeground(new
java.awt.Color(255, 255, 255));
btnayam2.setText("Ayam
Penyet");
btnayam2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnayam2ActionPerformed(evt);
}
});
jPanel1.add(btnayam2, new org.netbeans.lib.awtextra.AbsoluteConstraints(28,
112, -1, -1));
btnayam3.setBackground(new
java.awt.Color(0, 0, 0));
btnayam3.setFont(new
java.awt.Font("Giddyup Std", 0, 18)); // NOI18N
btnayam3.setForeground(new
java.awt.Color(255, 255, 255));
btnayam3.setText("Ayam
Goreng");
btnayam3.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnayam3ActionPerformed(evt);
}
});
jPanel1.add(btnayam3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(28, 143, -1, -1));
btnayam4.setBackground(new
java.awt.Color(0, 0, 0));
btnayam4.setFont(new
java.awt.Font("Giddyup Std", 0, 18)); // NOI18N
btnayam4.setForeground(new
java.awt.Color(255, 255, 255));
btnayam4.setText("Ayam
Tepung");
btnayam4.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnayam4ActionPerformed(evt);
}
});
jPanel1.add(btnayam4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(28, 174, -1, -1));
btnminum1.setBackground(new
java.awt.Color(0, 0, 0));
btnminum1.setFont(new
java.awt.Font("Giddyup Std", 0, 18)); // NOI18N
btnminum1.setForeground(new
java.awt.Color(255, 255, 255));
btnminum1.setText("Es Teh
Manis");
btnminum1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnminum1ActionPerformed(evt);
}
});
jPanel1.add(btnminum1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(28, 215, -1, -1));
btnminum2.setBackground(new java.awt.Color(0, 0, 0));
btnminum2.setFont(new
java.awt.Font("Giddyup Std", 0, 18)); // NOI18N
btnminum2.setForeground(new
java.awt.Color(255, 255, 255));
btnminum2.setText("Air
Mineral");
btnminum2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnminum2ActionPerformed(evt);
}
});
jPanel1.add(btnminum2, new org.netbeans.lib.awtextra.AbsoluteConstraints(28,
241, -1, -1));
btnminum3.setBackground(new
java.awt.Color(0, 0, 0));
btnminum3.setFont(new
java.awt.Font("Giddyup Std", 0, 18)); // NOI18N
btnminum3.setForeground(new
java.awt.Color(255, 255, 255));
btnminum3.setText("Soda");
btnminum3.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnminum3ActionPerformed(evt);
}
});
jPanel1.add(btnminum3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(28, 267, -1, -1));
btnhitung.setBackground(new
java.awt.Color(255, 0, 102));
btnhitung.setFont(new
java.awt.Font("Tahoma", 1, 11)); // NOI18N
btnhitung.setForeground(new
java.awt.Color(255, 255, 255));
btnhitung.setText("Hitung");
btnhitung.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent
evt) {
btnhitungActionPerformed(evt);
}
});
jPanel1.add(btnhitung, new
org.netbeans.lib.awtextra.AbsoluteConstraints(52, 348, -1, -1));
btnhitung1.setBackground(new
java.awt.Color(255, 0, 102));
btnhitung1.setFont(new
java.awt.Font("Tahoma", 1, 11)); // NOI18N
btnhitung1.setForeground(new
java.awt.Color(255, 255, 255));
btnhitung1.setText("Mulai");
btnhitung1.addActionListener(new java.awt.event.ActionListener()
{
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnhitung1ActionPerformed(evt);
}
});
jPanel1.add(btnhitung1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(160, 348, -1, -1));
btnkeluar.setBackground(new
java.awt.Color(255, 0, 102));
btnkeluar.setFont(new
java.awt.Font("Tahoma", 1, 11)); // NOI18N
btnkeluar.setForeground(new
java.awt.Color(255, 255, 255));
btnkeluar.setText("Keluar");
btnkeluar.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnkeluarActionPerformed(evt);
}
});
jPanel1.add(btnkeluar, new
org.netbeans.lib.awtextra.AbsoluteConstraints(272, 348, -1, -1));
x1.setBackground(new
java.awt.Color(255, 255, 255));
x1.setForeground(new java.awt.Color(255,
255, 255));
x1.setText("x");
jPanel1.add(x1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(211, 85, -1, -1));
x2.setForeground(new
java.awt.Color(255, 255, 255));
x2.setText("x");
jPanel1.add(x2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(211, 116, -1, -1));
x3.setForeground(new
java.awt.Color(255, 255, 255));
x3.setText("x");
jPanel1.add(x3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(211, 147, -1, -1));
x4.setForeground(new java.awt.Color(255, 255,
255));
x4.setText("x");
jPanel1.add(x4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(211, 178, -1, -1));
x5.setForeground(new
java.awt.Color(255, 255, 255));
x5.setText("x");
jPanel1.add(x5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(211, 219, -1, -1));
x6.setForeground(new
java.awt.Color(255, 255, 255));
x6.setText("x");
jPanel1.add(x6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(211, 271, -1, -1));
x7.setForeground(new
java.awt.Color(255, 255, 255));
x7.setText("x");
jPanel1.add(x7, new
org.netbeans.lib.awtextra.AbsoluteConstraints(211, 245, -1, -1));
jmlh1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jmlh1ActionPerformed(evt);
}
});
jPanel1.add(jmlh1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(235, 82, 30, -1));
jPanel1.add(jmlh2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(235, 113, 30, -1));
jPanel1.add(jmlh3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(235, 144, 30, -1));
jPanel1.add(jmlh4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(235, 175, 30, -1));
jPanel1.add(jmlh5, new
org.netbeans.lib.awtextra.AbsoluteConstraints(235, 216, 30, -1));
jPanel1.add(jmlh6, new
org.netbeans.lib.awtextra.AbsoluteConstraints(235, 242, 30, -1));
jmlhtotal.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jmlhtotalActionPerformed(evt);
}
});
jPanel1.add(jmlhtotal, new
org.netbeans.lib.awtextra.AbsoluteConstraints(180, 310, 95, -1));
jPanel1.add(lblayam1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(143, 82, 50, -1));
jPanel1.add(lblayam2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(143, 113, 50, -1));
jPanel1.add(lblayam3, new
org.netbeans.lib.awtextra.AbsoluteConstraints(143, 144, 50, -1));
jPanel1.add(lblayam4, new
org.netbeans.lib.awtextra.AbsoluteConstraints(143, 175, 50, -1));
jPanel1.add(lblminum1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(143, 216, 50, -1));
jPanel1.add(lblminum2, new
org.netbeans.lib.awtextra.AbsoluteConstraints(143, 242, 50, -1));
jPanel3.setBackground(new
java.awt.Color(0, 0, 0));
lblminum3.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
lblminum3ActionPerformed(evt);
}
});
jLabel2.setForeground(new java.awt.Color(255,
255, 255));
jLabel2.setText("Total
Pembelian");
javax.swing.GroupLayout jPanel3Layout =
new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(143, 143, 143)
.addComponent(lblminum3, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)
.addComponent(jmlh7,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(94, 94, 94)
.addComponent(jLabel2)))
.addContainerGap(155,
Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addContainerGap(269,
Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblminum3,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jmlh7,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addComponent(jLabel2)
.addGap(111, 111, 111))
);
jPanel1.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0,
0, 420, 440));
getContentPane().add(jPanel1, new
org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 418, 382));
pack();
}// </editor-fold>
private void
btnayam1ActionPerformed(java.awt.event.ActionEvent evt) {
//UNTUK AYAM BAKAR//
int ayambakar=15000;
if(btnayam1.isSelected()){
lblayam1.setText(""+btnayam1.getText());
lblayam1.setText(""+ayambakar);
}else{
lblayam1.setText("");
}
}
private void
btnayam2ActionPerformed(java.awt.event.ActionEvent evt) {
//UNTUK AYAM PENYET
int ayampenyet=20000;
if(btnayam2.isSelected()){
lblayam2.setText(""+btnayam2.getText());
lblayam2.setText(""+ayampenyet);
}else{
lblayam2.setText("");
}
}
private void
btnayam3ActionPerformed(java.awt.event.ActionEvent evt) {
//UNTUK AYAM GORENG
int ayamgoreng=10000;
if(btnayam3.isSelected()){
lblayam3.setText(""+btnayam3.getText());
lblayam3.setText(""+ayamgoreng);
}else{
lblayam3.setText("");
}
// TODO add your handling code here:
}
private void
btnayam4ActionPerformed(java.awt.event.ActionEvent evt) {
//UNTUK AYAM TEPUNG
int ayamtepung=8000;
if(btnayam4.isSelected()){
lblayam4.setText(""+btnayam4.getText());
lblayam4.setText(""+ayamtepung);
}else{
lblayam4.setText("");
}
// TODO add your handling code here:
}
private void
btnminum1ActionPerformed(java.awt.event.ActionEvent evt) {
//UNTUK ES TEH
int estehmanis=5000;
if(btnminum1.isSelected()){
lblminum1.setText(""+btnminum1.getText());
lblminum1.setText(""+estehmanis);
}else{
lblminum1.setText("");
}
// TODO add your handling code here:
}
private void
btnminum2ActionPerformed(java.awt.event.ActionEvent evt) {
//UNTUK AIR MINERAL
int airmineral=3000;
if(btnminum2.isSelected()){
lblminum2.setText(""+btnminum2.getText());
lblminum2.setText(""+airmineral);
}else{
lblminum2.setText("");
}
// TODO add your handling code here:
}
private void
btnminum3ActionPerformed(java.awt.event.ActionEvent evt) {
// UNTUK SODA
int soda=6000;
if(btnminum3.isSelected()){
lblminum3.setText(""+btnminum3.getText());
lblminum3.setText(""+soda);
}else{
lblminum3.setText("");
}
// TODO add your handling code here:
}
private void
btnhitungActionPerformed(java.awt.event.ActionEvent evt) {
// UNTUK HITUNG
int total=0;
if(btnayam1.isSelected()){
String AB=jmlh1.getText();
int
jmlhAB=Integer.parseInt(AB);
int HargaAB=jmlhAB*15000;
total=total+HargaAB;
}
if(btnayam2.isSelected()){
String AP=jmlh2.getText();
int
jmlhAP=Integer.parseInt(AP);
int HargaAP=jmlhAP*20000;
total=total+HargaAP;
}
if(btnayam3.isSelected()){
String AG=jmlh3.getText();
int
jmlhAG=Integer.parseInt(AG);
int HargaAG=jmlhAG*10000;
total=total+HargaAG;
}
if(btnayam4.isSelected()){
String AT=jmlh4.getText();
int
jmlhAT=Integer.parseInt(AT);
int HargaAT=jmlhAT*8000;
total=total+HargaAT;
}
if(btnminum1.isSelected()){
String ET=jmlh5.getText();
int
jmlhET=Integer.parseInt(ET);
int HargaET=jmlhET*5000;
total=total+HargaET;
}
if(btnminum2.isSelected()){
String AM=jmlh6.getText();
int
jmlhAM=Integer.parseInt(AM);
int HargaAM=jmlhAM*3000;
total=total+HargaAM;
}
if(btnminum3.isSelected()){
String SO=jmlh7.getText();
int
jmlhSO=Integer.parseInt(SO);
int HargaSO=jmlhSO*6000;
total=total+HargaSO;
}
jmlhtotal.setText("Rp"+total+",-");
// TODO add your handling code here:
}
private void
btnhitung1ActionPerformed(java.awt.event.ActionEvent evt) {
// UNTUK BUTTON MULAI
jmlh1.setEditable(false);
jmlh1.setText("");
jmlh2.setEditable(false);
jmlh2.setText("");
jmlh3.setEditable(false);
jmlh3.setText("");
jmlh4.setEditable(false);
jmlh4.setText("");
jmlh5.setEditable(false);
jmlh5.setText("");
jmlh6.setEditable(false);
jmlh6.setText("");
jmlh7.setEditable(false);
jmlh7.setText("");
// TODO add your handling code here:
}
private void
btnkeluarActionPerformed(java.awt.event.ActionEvent evt) {
int x=
JOptionPane.showConfirmDialog(null,"Keluar
Program","Exit",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if(x==JOptionPane.YES_OPTION){
System.exit(0);
}
}
private void
jmlhtotalActionPerformed(java.awt.event.ActionEvent evt) {
// // TODO add your handling code here:
}
private void jmlh1ActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
}
private void
lblminum3ActionPerformed(java.awt.event.ActionEvent evt) {
// 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(ulangcoba.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ulangcoba.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ulangcoba.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ulangcoba.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(()
-> {
new ulangcoba().setVisible(true);
});
}
// Variables declaration - do not
modify
private javax.swing.JRadioButton btnayam1;
private javax.swing.JRadioButton btnayam2;
private javax.swing.JRadioButton btnayam3;
private javax.swing.JRadioButton btnayam4;
private javax.swing.JButton btnhitung;
private javax.swing.JButton btnhitung1;
private javax.swing.JButton btnkeluar;
private javax.swing.JRadioButton btnminum1;
private javax.swing.JRadioButton btnminum2;
private javax.swing.JRadioButton btnminum3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JTextField jmlh1;
private javax.swing.JTextField jmlh2;
private javax.swing.JTextField jmlh3;
private javax.swing.JTextField jmlh4;
private javax.swing.JTextField jmlh5;
private javax.swing.JTextField jmlh6;
private javax.swing.JTextField jmlh7;
private javax.swing.JTextField jmlhtotal;
private javax.swing.JTextField lblayam1;
private javax.swing.JTextField lblayam2;
private javax.swing.JTextField lblayam3;
private javax.swing.JTextField lblayam4;
private javax.swing.JTextField lblminum1;
private javax.swing.JTextField lblminum2;
private javax.swing.JTextField lblminum3;
private javax.swing.JLabel x1;
private javax.swing.JLabel x2;
private javax.swing.JLabel x3;
private javax.swing.JLabel x4;
private javax.swing.JLabel x5;
private javax.swing.JLabel x6;
private javax.swing.JLabel x7;
// End of variables declaration
}
Sekian penjelasan dari saya.