Assalamu’alaikum..Wr..Wb..
Deskripsi program aplikasi kasir.
Program Aplikasi Kasir rumah makan aneh, tujuan dibuatnya aplikasi ini untuk mempermudah perhitungan atau kinerja kasir.
- Menu
- Hargasatuan
- Jumlahbeli
- Totalharga
Berikut hasil Screanshoot pada XAMPPnya :
Tampilan pada design :
Ini hasil runnya :
Source kode untuk bayar :
Ini source kodenya :
* * 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. */ package ezauas; import com.mysql.jdbc.Statement; import java.sql.DriverManager; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import koneksi.konek; /** * * @author User */ public class TUGASUAS extends javax.swing.JFrame { String nm_mknan=””; int harga_mknan; int jml_beli; int jumlah_hrg; int bayar,beli,Harga; /** * Creates new form TUGASUAS */ public TUGASUAS() { 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() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); HARGA = new javax.swing.JTextField(); BELI = new javax.swing.JTextField(); TOTAL = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); CB1 = new javax.swing.JComboBox<>(); jScrollPane2 = new javax.swing.JScrollPane(); table = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setFont(new java.awt.Font(“Sylfaen”, 1, 14)); // NOI18N jLabel1.setForeground(new java.awt.Color(102, 0, 153)); jLabel1.setText(“KASIR RUMAH MAKAN ANEH”); jLabel2.setText(“MENU”); jLabel3.setText(“HARGA SATUAN”); jLabel4.setText(“JUMLAH BELI”); jLabel5.setText(“TOTAL HARGA”); HARGA.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { HARGAActionPerformed(evt); } }); TOTAL.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { TOTALActionPerformed(evt); } }); jButton1.setText(“BAYAR”); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText(“CANCEL”); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText(“CLOSE”); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); CB1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { “PILIH MENU”, “Ayam bakar”, “Sate ayam”, “Soto ayam”, “Rendang”, “Es teh manis”, “Teh manis” })); CB1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CB1ActionPerformed(evt); } }); table.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { “Title 1”, “Title 2”, “Title 3”, “Title 4” } )); jScrollPane2.setViewportView(table); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addComponent(jButton1) .addGap(92, 92, 92) .addComponent(jButton2) .addGap(72, 72, 72) .addComponent(jButton3)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(28, 28, 28) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addGap(1, 1, 1) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(HARGA, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(CB1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(BELI, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(TOTAL, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGap(92, 92, 92) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(274, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(6, 6, 6) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(CB1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(HARGA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(BELI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(TOTAL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(31, 31, 31) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2) .addComponent(jButton3)) .addContainerGap(45, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Harga =Integer.parseInt(HARGA.getText()); beli = Integer.parseInt(BELI.getText()); bayar = Harga * beli ; TOTAL.setText(“”+bayar); String menu=(String)CB1.getSelectedItem(); String hargasatuan=HARGA.getText(); String jumlahbeli=BELI.getText(); String totalharga=TOTAL.getText(); try{ Statement sta=(Statement) konek.GetConnection().createStatement(); sta.executeUpdate(“INSERT INTO eza VALUES(‘”+menu+”‘,'”+hargasatuan+”‘,'”+jumlahbeli+”‘,'”+totalharga+”‘)”); }catch (Exception e){ JOptionPane.showMessageDialog(null,” Terima kasih”); } DefaultTableModel tbl = new DefaultTableModel(); tbl.addColumn(“MENU”); tbl.addColumn(“HARGA SATUAN”); tbl.addColumn(“JUMLAH BELI”); tbl.addColumn(“TOTAL HARGA”); table.setModel(tbl); try{ Statement sta=(Statement) konek.GetConnection().createStatement(); ResultSet res=sta.executeQuery(“SELECT * FROM eza”); while(res.next()) { tbl.addRow(new Object[]{ res.getString(“menu”), res.getString(“hargasatuan”), res.getString(“jumlahbeli”), res.getString(“totalharga”), }); table.setModel(tbl); } }catch (Exception e){ JOptionPane.showMessageDialog(null,”Terjadikesalahan saat memilih Menu”); } } private void CB1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: nm_mknan=(String)CB1.getSelectedItem(); if(nm_mknan==”Ayam bakar”) { harga_mknan=20000; }else if (nm_mknan==”Sate ayam”) { harga_mknan=30000; }else if (nm_mknan==”Soto ayam”) { harga_mknan=15000; }else if (nm_mknan==”Rendang”) { harga_mknan=30000; }else if (nm_mknan==”Es teh manis”) { harga_mknan=10000; }else if (nm_mknan==”Teh manis”) { harga_mknan=8500; } //gantiformat=NumberFormat.getNumberInstance(Locale.ENGLISH).format(harga_mknan); //token=new StringTokenizer(gantiformat,”.”); //gantiformat=token.nextToken(); //gantiformat=gantiformat.replace(‘.’,’.’ ); HARGA.setText(“”+harga_mknan); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int answer = JOptionPane.showConfirmDialog(null, “Yakin anda ingin membatalkan pesanan”, “Selesai”, JOptionPane.CANCEL_OPTION); if (answer== JOptionPane.OK_OPTION) CB1.setSelectedIndex(-1); HARGA.setText(“”); BELI.setText(“”); TOTAL.setText(“”); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int answer = JOptionPane.showConfirmDialog(null, “Apakah anda ingin keluar”, “Selesai”, JOptionPane.OK_OPTION); if (answer == JOptionPane.OK_OPTION){ dispose(); } } private void HARGAActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Harga =Integer.parseInt(HARGA.getText()); beli = Integer.parseInt(BELI.getText()); } private void TOTALActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Harga =Integer.parseInt(HARGA.getText()); beli = Integer.parseInt(BELI.getText()); HARGA.setText(“”); } public void database(){ DefaultTableModel tbl = new DefaultTableModel(); tbl.addColumn(“MENU”); tbl.addColumn(“HARGA SATUAN”); tbl.addColumn(“JUMLAH BELI”); tbl.addColumn(“TOTAL HARGA”); table.setModel(tbl); try{ Statement sta=(Statement) konek.GetConnection().createStatement(); ResultSet res=sta.executeQuery(“SELECT * FROM eza”); while(res.next()) { tbl.addRow(new Object[]{ res.getString(“menu”), res.getString(“hargasatuan”), res.getString(“jumlahbeli”), res.getString(“totalharga”), }); table.setModel(tbl); } }catch (Exception e){ JOptionPane.showMessageDialog(null,”Terjadikesalahan saat memilih Menu”); } } /** * @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. */ 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(TUGASUAS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(TUGASUAS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(TUGASUAS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(TUGASUAS.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 TUGASUAS().setVisible(true); } }); } // Variables declaration – do not modify private javax.swing.JTextField BELI; private javax.swing.JComboBox<String> CB1; private javax.swing.JTextField HARGA; private javax.swing.JTextField TOTAL; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTable table; // End of variables declaration }
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
Sekian post saya kali ini kurang dan lebihnya saya mohon maaf,
Wassalamu’alaikum..Wr..Wb.