PROJECT SEDERHANA PENGIRIMAN BARANG JAVA (Netbean)
Pada kesempatan kali ini saya membuat program sederhana pengiriman barang dengan menggunakan Netbean. program ini di tujukan untuk mempermudah jasa pengiriman barang dalam hal menginput nama pengirim, kota asal, kota tujuan, dan juga menghitung biaya pengiriman.
Berikut komponen - komponen yang digunakan :
Berikut gambar dari JFrame/form :
Gambar Tabel Data Base :
Berikut Source Codenya :
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<tugasuas1.TugasUas161011700008> toRemove = new ArrayList<tugasuas1.TugasUas161011700008>(selected.length);
for (int idx = 0; idx < selected.length; idx++) {
tugasuas1.TugasUas161011700008 t = list.get(masterTable.convertRowIndexToModel(selected[idx]));
toRemove.add(t);
entityManager.remove(t);
}
list.removeAll(toRemove);
}
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {
tugasuas1.TugasUas161011700008 t = new tugasuas1.TugasUas161011700008();
entityManager.persist(t);
list.add(t);
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<tugasuas1.TugasUas161011700008> merged = new ArrayList<tugasuas1.TugasUas161011700008>(list.size());
for (tugasuas1.TugasUas161011700008 t : list) {
merged.add(entityManager.merge(t));
}
list.clear();
list.addAll(merged);
}
}
private void prosesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int JumlahBarang=Integer.parseInt(jumlahBarangField.getText());
int BiayaPengiriman=Integer.parseInt(biayaPengirimanField.getText());
int TotalHarga=JumlahBarang*BiayaPengiriman;
totalHargaField.setText(""+TotalHarga);
}
SEKIAN ...
KEEP CALM AND STAY CASUAL 👟
Berikut komponen - komponen yang digunakan :
- Label
- TextField
- Button
Berikut gambar dari JFrame/form :
Berikut Source Codenya :
- Refresh
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);
}
- Delete
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {
int[] selected = masterTable.getSelectedRows();
List<tugasuas1.TugasUas161011700008> toRemove = new ArrayList<tugasuas1.TugasUas161011700008>(selected.length);
for (int idx = 0; idx < selected.length; idx++) {
tugasuas1.TugasUas161011700008 t = list.get(masterTable.convertRowIndexToModel(selected[idx]));
toRemove.add(t);
entityManager.remove(t);
}
list.removeAll(toRemove);
}
- New
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {
tugasuas1.TugasUas161011700008 t = new tugasuas1.TugasUas161011700008();
entityManager.persist(t);
list.add(t);
int row = list.size() - 1;
masterTable.setRowSelectionInterval(row, row);
masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
}
- Save
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
try {
entityManager.getTransaction().commit();
entityManager.getTransaction().begin();
} catch (RollbackException rex) {
rex.printStackTrace();
entityManager.getTransaction().begin();
List<tugasuas1.TugasUas161011700008> merged = new ArrayList<tugasuas1.TugasUas161011700008>(list.size());
for (tugasuas1.TugasUas161011700008 t : list) {
merged.add(entityManager.merge(t));
}
list.clear();
list.addAll(merged);
}
}
- Process
private void prosesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int JumlahBarang=Integer.parseInt(jumlahBarangField.getText());
int BiayaPengiriman=Integer.parseInt(biayaPengirimanField.getText());
int TotalHarga=JumlahBarang*BiayaPengiriman;
totalHargaField.setText(""+TotalHarga);
}
SEKIAN ...
KEEP CALM AND STAY CASUAL 👟
Komentar
Posting Komentar