Membuat Program Kasir Java dan Database
Nama :Berlian Nandawidi Hardi
NIM : 171021400305
Kelas: 02Tple003
NIM : 171021400305
Kelas: 02Tple003
Program kasir beserta tabel
- Deskripsi
- Keterangan
- JTextField 1 Variable Name ganti dengan TxtRBNG, JTextField 2 = TxtRBMG, JTextField 3 = TxtRBSA, JTextField 4 = TxtRBSK, JTextField 5 = TxtRBNS, JTextField 6 = TxtjmlNG, JTextField 7 = TxtjmlMG, JTextField 8 = TxtjmlSA, JTextField 9 = TxtjmlSK, JTextField 10 = TxtjmlNS, JTextField 11 = TxtjmlHarga.
- JRadioButton 1 Variabel Name ganti dengan RBNG, JRadioButton 2 = RBMG, JRadioButton 3 = RBSA, JRadioButton 4 = RBSK, JRadioButton 5 = RBNS.
- Source codenya
/*
* 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 programkasir;
import java.awt.EventQueue;
import java.beans.Beans;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.RollbackException;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
*
* @author ASUS
*/
public class TabelKasir extends JPanel {
public TabelKasir() {
initComponents();
if (!Beans.isDesignTime()) {
entityManager.getTransaction().begin();
}
}
/**
* 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() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("tabelkasir?zeroDateTimeBehavior=convertToNullPU").createEntityManager();
query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT p FROM Programkasir_1 p");
list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());
masterScrollPane = new javax.swing.JScrollPane();
masterTable = new javax.swing.JTable();
noLabel = new javax.swing.JLabel();
jumlahHargaLabel = new javax.swing.JLabel();
noField = new javax.swing.JTextField();
TxtRBNG = new javax.swing.JTextField();
TxtRBMG = new javax.swing.JTextField();
TxtRBSA = new javax.swing.JTextField();
TxtRBSK = new javax.swing.JTextField();
TxtRBNS = new javax.swing.JTextField();
TxtjmlHarga = new javax.swing.JTextField();
saveButton = new javax.swing.JButton();
refreshButton = new javax.swing.JButton();
newButton = new javax.swing.JButton();
deleteButton = new javax.swing.JButton();
RBNG = new javax.swing.JRadioButton();
RBMG = new javax.swing.JRadioButton();
RBSA = new javax.swing.JRadioButton();
RBSK = new javax.swing.JRadioButton();
RBNS = new javax.swing.JRadioButton();
jButton1 = new javax.swing.JButton();
BtnHapus = new javax.swing.JButton();
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();
TxtjmlNG = new javax.swing.JTextField();
TxtjmlMG = new javax.swing.JTextField();
TxtjmlSA = new javax.swing.JTextField();
TxtjmlSK = new javax.swing.JTextField();
TxtjmlNS = new javax.swing.JTextField();
FormListener formListener = new FormListener();
org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, list, masterTable);
org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${no}"));
columnBinding.setColumnName("No");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nasiGoreng}"));
columnBinding.setColumnName("Nasi Goreng");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${mieGoreng}"));
columnBinding.setColumnName("Mie Goreng");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${sotoAyam}"));
columnBinding.setColumnName("Soto Ayam");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${sopKambing}"));
columnBinding.setColumnName("Sop Kambing");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nasi}"));
columnBinding.setColumnName("Nasi");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${jumlahHarga}"));
columnBinding.setColumnName("Jumlah Harga");
columnBinding.setColumnClass(Integer.class);
bindingGroup.addBinding(jTableBinding);
masterScrollPane.setViewportView(masterTable);
noLabel.setText("No:");
jumlahHargaLabel.setText("Jumlah Harga:");
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.no}"), noField, org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue("null");
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), noField, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.nasiGoreng}"), TxtRBNG, org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue("null");
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), TxtRBNG, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
TxtRBNG.addActionListener(formListener);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.mieGoreng}"), TxtRBMG, org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue("null");
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), TxtRBMG, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.sotoAyam}"), TxtRBSA, org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue("null");
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), TxtRBSA, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.sopKambing}"), TxtRBSK, org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue("null");
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), TxtRBSK, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.nasi}"), TxtRBNS, org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue("null");
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), TxtRBNS, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.jumlahHarga}"), TxtjmlHarga, org.jdesktop.beansbinding.BeanProperty.create("text"));
binding.setSourceUnreadableValue("null");
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), TxtjmlHarga, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
saveButton.setText("Save");
saveButton.addActionListener(formListener);
refreshButton.setText("Refresh");
refreshButton.addActionListener(formListener);
newButton.setText("New");
newButton.addActionListener(formListener);
deleteButton.setText("Delete");
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), deleteButton, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
deleteButton.addActionListener(formListener);
RBNG.setText("Nasi Goreng:");
RBNG.addActionListener(formListener);
RBMG.setText("Mie Goreng:");
RBMG.addActionListener(formListener);
RBSA.setText("Soto Ayam:");
RBSA.addActionListener(formListener);
RBSK.setText("Sop Kambing:");
RBSK.addActionListener(formListener);
RBNS.setText("Nasi:");
RBNS.addActionListener(formListener);
jButton1.setText("Hitung");
jButton1.addActionListener(formListener);
BtnHapus.setText("Hapus");
BtnHapus.addActionListener(formListener);
jLabel1.setText("x");
jLabel2.setText("x");
jLabel3.setText("x");
jLabel4.setText("x");
jLabel5.setText("x");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(newButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(deleteButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(refreshButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(saveButton))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(masterScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 586, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(RBSA)
.addGap(33, 33, 33)
.addComponent(TxtRBSA, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(TxtjmlSA, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addGap(23, 23, 23)
.addComponent(jumlahHargaLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(TxtjmlHarga, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(RBNS)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(TxtRBNS, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(RBSK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(TxtRBSK, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(RBMG)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(TxtRBMG, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(RBNG, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(noLabel)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(noField, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TxtRBNG, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(TxtjmlMG, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(TxtjmlSK, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(TxtjmlNS, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(TxtjmlNG, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(0, 192, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(94, 94, 94)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(BtnHapus)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {deleteButton, newButton, refreshButton, saveButton});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(masterScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(noField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(noLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(TxtjmlNG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(TxtRBNG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(RBNG))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(RBMG)
.addComponent(TxtRBMG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(TxtjmlMG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(RBSA)
.addComponent(TxtRBSA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(TxtjmlSA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(RBSK)
.addComponent(TxtRBSK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(TxtjmlSK, 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(TxtRBNS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(RBNS)
.addComponent(jLabel5)
.addComponent(TxtjmlNS, 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(jumlahHargaLabel)
.addComponent(TxtjmlHarga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(BtnHapus))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(saveButton)
.addComponent(refreshButton)
.addComponent(deleteButton)
.addComponent(newButton)))
);
bindingGroup.bind();
}
// Code for dispatching events from components to event handlers.
private class FormListener implements java.awt.event.ActionListener {
FormListener() {}
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (evt.getSource() == TxtRBNG) {
TabelKasir.this.TxtRBNGActionPerformed(evt);
}
else if (evt.getSource() == saveButton) {
TabelKasir.this.saveButtonActionPerformed(evt);
}
else if (evt.getSource() == refreshButton) {
TabelKasir.this.refreshButtonActionPerformed(evt);
}
else if (evt.getSource() == newButton) {
TabelKasir.this.newButtonActionPerformed(evt);
}
else if (evt.getSource() == deleteButton) {
TabelKasir.this.deleteButtonActionPerformed(evt);
}
else if (evt.getSource() == RBNG) {
TabelKasir.this.RBNGActionPerformed(evt);
}
else if (evt.getSource() == RBMG) {
TabelKasir.this.RBMGActionPerformed(evt);
}
else if (evt.getSource() == RBSA) {
TabelKasir.this.RBSAActionPerformed(evt);
}
else if (evt.getSource() == RBSK) {
TabelKasir.this.RBSKActionPerformed(evt);
}
else if (evt.getSource() == RBNS) {
TabelKasir.this.RBNSActionPerformed(evt);
}
else if (evt.getSource() == jButton1) {
TabelKasir.this.jButton1ActionPerformed(evt);
}
else if (evt.getSource() == BtnHapus) {
TabelKasir.this.BtnHapusActionPerformed(evt);
}
}
}// </editor-fold>
@SuppressWarnings("unchecked")
private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
entityManager.getTransaction().rollback();
entityManager.getTransaction().begin();
java.util.Collection data = query.getResultList();
for (Object entity : data) {
entityManager.refresh(entity);
}
list.clear();
list.addAll(data);
}
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {
int[] selected = masterTable.getSelectedRows();
List<programkasir.Programkasir_1> toRemove = new ArrayList<programkasir.Programkasir_1>(selected.length);
for (int idx = 0; idx < selected.length; idx++) {
programkasir.Programkasir_1 p = list.get(masterTable.convertRowIndexToModel(selected[idx]));
toRemove.add(p);
entityManager.remove(p);
}
list.removeAll(toRemove);
}
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {
programkasir.Programkasir_1 p = new programkasir.Programkasir_1();
entityManager.persist(p);
list.add(p);
int row = list.size() - 1;
masterTable.setRowSelectionInterval(row, row);
masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
}
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
try {
entityManager.getTransaction().commit();
entityManager.getTransaction().begin();
} catch (RollbackException rex) {
rex.printStackTrace();
entityManager.getTransaction().begin();
List<programkasir.Programkasir_1> merged = new ArrayList<programkasir.Programkasir_1>(list.size());
for (programkasir.Programkasir_1 p : list) {
merged.add(entityManager.merge(p));
}
list.clear();
list.addAll(merged);
}
}
private void TxtRBNGActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void RBNGActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int nasigoreng=15000;
if(RBNG.isSelected()){
TxtRBNG.setText("" +RBNG.getText());
TxtRBNG.setText("" +nasigoreng);
}else{
TxtRBNG.setText("");}
}
private void RBMGActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int miegoreng=15000;
if(RBMG.isSelected()){
TxtRBMG.setText(""+RBMG.getText());
TxtRBMG.setText(""+miegoreng);
}else{
TxtRBMG.setText("");}
}
private void RBSAActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int sotoayam=15000;
if(RBSA.isSelected()){
TxtRBSA.setText("" +RBSA.getText());
TxtRBSA.setText("" +sotoayam);
}else{
TxtRBSA.setText("");}
}
private void RBSKActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int sopkambing=13000;
if(RBSK.isSelected()){
TxtRBSK.setText("" +RBSK.getText());
TxtRBSK.setText("" +sopkambing);
}else{
TxtRBSK.setText("");
}
}
private void RBNSActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int nasi=5000;
if(RBNS.isSelected()){
TxtRBNS.setText("" +RBNS.getText());
TxtRBNS.setText("" +nasi);
}else{
TxtRBNS.setText("");
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int total=0;
if (RBNG.isSelected()){
String NG=TxtjmlNG.getText();
int jmlNG=Integer.parseInt(NG);
int HargaNG=jmlNG*15000;
total=total+HargaNG;
}
if (RBMG.isSelected()){
String MG=TxtjmlMG.getText();
int jmlMG=Integer.parseInt(MG);
int HargaMG=jmlMG*15000;
total=total+HargaMG;
}
if (RBSA.isSelected()){
String SA=TxtjmlSA.getText();
int jmlSA=Integer.parseInt(SA);
int HargaSA=jmlSA*15000;
total=total+HargaSA;
}
if (RBSK.isSelected()){
String SK=TxtjmlSK.getText();
int jmlSK=Integer.parseInt(SK);
int HargaSK=jmlSK*25000;
total=total+HargaSK;
}
if (RBNS.isSelected()){
String NS=TxtjmlNS.getText();
int jmlNS=Integer.parseInt(NS);
int HargaNS=jmlNS*5000;
total=total+HargaNS;
}
TxtjmlHarga.setText("" +total);
}
private void BtnHapusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
TxtjmlNG.setEditable(false);
TxtjmlNG.setText("");
TxtjmlMG.setEditable(false);
TxtjmlMG.setText("");
TxtjmlSA.setEditable(false);
TxtjmlSA.setText("");
TxtjmlSK.setEditable(false);
TxtjmlSK.setText("");
TxtjmlNS.setEditable(false);
TxtjmlNS.setText("");
TxtjmlHarga.setText("");
}
// Variables declaration - do not modify
private javax.swing.JButton BtnHapus;
private javax.swing.JRadioButton RBMG;
private javax.swing.JRadioButton RBNG;
private javax.swing.JRadioButton RBNS;
private javax.swing.JRadioButton RBSA;
private javax.swing.JRadioButton RBSK;
private javax.swing.JTextField TxtRBMG;
private javax.swing.JTextField TxtRBNG;
private javax.swing.JTextField TxtRBNS;
private javax.swing.JTextField TxtRBSA;
private javax.swing.JTextField TxtRBSK;
private javax.swing.JTextField TxtjmlHarga;
private javax.swing.JTextField TxtjmlMG;
private javax.swing.JTextField TxtjmlNG;
private javax.swing.JTextField TxtjmlNS;
private javax.swing.JTextField TxtjmlSA;
private javax.swing.JTextField TxtjmlSK;
private javax.swing.JButton deleteButton;
private javax.persistence.EntityManager entityManager;
private javax.swing.JButton jButton1;
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.JLabel jumlahHargaLabel;
private java.util.List<programkasir.Programkasir_1> list;
private javax.swing.JScrollPane masterScrollPane;
private javax.swing.JTable masterTable;
private javax.swing.JButton newButton;
private javax.swing.JTextField noField;
private javax.swing.JLabel noLabel;
private javax.persistence.Query query;
private javax.swing.JButton refreshButton;
private javax.swing.JButton saveButton;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration
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(TabelKasir.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TabelKasir.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TabelKasir.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TabelKasir.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame();
frame.setContentPane(new TabelKasir());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
});
}
}
- Tampilan Program Database Kasir
- flowchart
Run succes
Komentar
Posting Komentar