Source Code JFrame Form
/*
* 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 JavaFrameOOP;
import java.awt.event.ActionEvent;
import javax.swing.JOptionPane;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
/**
*
* @author aghni
*/
public class NewJFrame extends javax.swing.JFrame {
/**
* Creates new form NewJFrame
*/
public NewJFrame() {
initComponents();
}
cBarang brg[] = new cBarang[5];
cPelanggan plg[] = new cPelanggan[10];
int i; boolean isi, sama;
JFrame frame = new JFrame();
String row[][] = new String[4][5];
/**
* 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() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel5 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
namabrg = new javax.swing.JTextField();
jScrollPane3 = new javax.swing.JScrollPane();
jTable3 = new javax.swing.JTable();
tambahbrg = new javax.swing.JButton();
hapusbrg = new javax.swing.JButton();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
stckbrg = new javax.swing.JTextField();
idbrg = new javax.swing.JTextField();
hrgbrg = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
idplg = new javax.swing.JTextField();
namaplg = new javax.swing.JTextField();
alamat = new javax.swing.JTextField();
nomer = new javax.swing.JTextField();
tambahplg = new javax.swing.JButton();
hapusplg = new javax.swing.JButton();
jScrollPane4 = new javax.swing.JScrollPane();
jTable4 = new javax.swing.JTable();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
idplgbl = new javax.swing.JTextField();
namaplgbl = new javax.swing.JTextField();
idbrgbl = new javax.swing.JTextField();
namabrgbl = new javax.swing.JTextField();
jLabel22 = new javax.swing.JLabel();
jmlhbeli = new javax.swing.JSpinner();
jLabel23 = new javax.swing.JLabel();
beli = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
ttlpemb = new javax.swing.JTextArea();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jLabel25 = new javax.swing.JLabel();
jLabel26 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel8.setText("ID Barang ");
jLabel9.setText("Nama Barang");
jLabel10.setText("Harga Barang");
jTable3.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"ID Barang", "Nama Barang", "Harga Barang", "Stock"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jTable3.setGridColor(new java.awt.Color(50, 100, 100));
jTable3.setInheritsPopupMenu(true);
jTable3.setName(""); // NOI18N
jScrollPane3.setViewportView(jTable3);
tambahbrg.setText("TAMBAH");
tambahbrg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tambahbrgActionPerformed(evt);
}
});
hapusbrg.setText("HAPUS");
hapusbrg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hapusbrgActionPerformed(evt);
}
});
jLabel15.setText(" : Rp");
jLabel16.setText("Stock Barang :");
idbrg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
idbrgActionPerformed(evt);
}
});
jLabel11.setText(":");
jLabel12.setText(":");
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane3)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(jLabel8)
.addComponent(jLabel10))
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jLabel15)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(hrgbrg, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(tambahbrg)
.addGap(18, 18, 18)
.addComponent(hapusbrg, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel16)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(stckbrg, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(idbrg, javax.swing.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
.addComponent(namabrg))))))
.addGap(80, 80, 80))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(idbrg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(namabrg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(jLabel15)
.addComponent(jLabel16)
.addComponent(stckbrg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(hrgbrg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tambahbrg)
.addComponent(hapusbrg))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jTabbedPane1.addTab("Barang", jPanel5);
idplg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
idplgActionPerformed(evt);
}
});
namaplg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
namaplgActionPerformed(evt);
}
});
alamat.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
alamatActionPerformed(evt);
}
});
tambahplg.setText("TAMBAH");
tambahplg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tambahplgActionPerformed(evt);
}
});
hapusplg.setText("HAPUS");
hapusplg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hapusplgActionPerformed(evt);
}
});
jTable4.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"ID Pelanggan", "Nama Pelanggan", "Alamat", "Nomor Telepon"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jScrollPane4.setViewportView(jTable4);
jLabel6.setText("ID Pelanggan");
jLabel7.setText("Nama Pelanggan");
jLabel21.setText("Alamat");
jLabel24.setText("Nomor Telepon");
jLabel13.setText(": ");
jLabel14.setText(": ");
jLabel17.setText(": ");
jLabel18.setText(": ");
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(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(98, 98, 98)
.addComponent(tambahplg, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(hapusplg, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel24)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel18))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(jLabel21)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel17))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel14))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel13)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(namaplg, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(alamat, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(nomer)
.addComponent(idplg))))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(idplg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jLabel13))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(namaplg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(jLabel14))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(alamat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel21)
.addComponent(jLabel17))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel24)
.addComponent(jLabel18))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tambahplg)
.addComponent(hapusplg))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(36, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Pelanggan", jPanel2);
namaplgbl.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
namaplgblActionPerformed(evt);
}
});
namabrgbl.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
namabrgblActionPerformed(evt);
}
});
jLabel22.setText("Jumlah Pembelian :");
jLabel23.setText("Total Pembelian :");
beli.setText("BELI");
beli.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
beliActionPerformed(evt);
}
});
ttlpemb.setColumns(20);
ttlpemb.setRows(5);
jScrollPane1.setViewportView(ttlpemb);
jLabel2.setText("ID Pelanggan");
jLabel3.setText("Nama Pelanggan");
jLabel4.setText("ID Barang");
jLabel5.setText("Nama Barang");
jLabel19.setText(":");
jLabel20.setText(": ");
jLabel25.setText(": ");
jLabel26.setText(": ");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(beli, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
.addComponent(jLabel22)
.addGap(18, 18, 18)
.addComponent(jmlhbeli, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(87, 87, 87)
.addComponent(jLabel23)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel5)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(namaplgbl)
.addComponent(idplgbl)
.addComponent(namabrgbl)
.addComponent(idbrgbl))))
.addGap(10, 10, 10))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(idplgbl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(jLabel19))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(namaplgbl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jLabel20))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(idbrgbl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(jLabel25))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel26))
.addComponent(namabrgbl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(43, 43, 43)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel22)
.addComponent(jmlhbeli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel23))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(beli, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(48, Short.MAX_VALUE))
);
jTabbedPane1.addTab("Pembelian", jPanel3);
jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
jLabel1.setText("PROGRAM STATIONERY");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 566, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(18, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(185, 185, 185))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTabbedPane1)
.addContainerGap())
);
pack();
}// </editor-fold>
private void tambahbrgActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
isi = false;
sama = false;
i=0;
byte j=0;
DefaultTableModel modelbrg = (DefaultTableModel) jTable3.getModel();
String id = idbrg.getText();
String name = namabrg.getText();
int hrg = Integer.parseInt(hrgbrg.getText());
int stc = Integer.parseInt(stckbrg.getText());
while(j<modelbrg.getRowCount() && sama==false){
if(id.equalsIgnoreCase(brg[j].getIDBrg()) || name.equalsIgnoreCase(brg[j].getNamaBrg())) {
sama = true;
JOptionPane.showMessageDialog(frame, "Data Barang Sudah Ada!");
}
else j++;
}
while(i<5 && isi == false && sama== false){
if(brg[i] == null){
brg[i] = new cBarang(id, name, hrg, stc);
row[i][0] = id;
row[i][1] = name;
row[i][2] = hrgbrg.getText();
row[i][3] = stckbrg.getText();
modelbrg.addRow(row[i]);
isi = true;
JOptionPane.showMessageDialog(frame, "Data Barang Berhasil Ditambahkan!");
}
else i++;
};
if(i>5) JOptionPane.showMessageDialog(frame, "Daftar Barang Telah Penuh!");
idbrg.setText("");
namabrg.setText("");
hrgbrg.setText("");
stckbrg.setText("");
}
private void idplgActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void namaplgActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void alamatActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void hapusplgActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int j=0;
isi = true;
int hs = JOptionPane.showConfirmDialog(frame, "Hapus Data Pelanggan?");
if(hs==JOptionPane.YES_OPTION){
while(j<5 && isi == true){
if(idplg.getText().equalsIgnoreCase(plg[j].getIDPlgn())){
if(namaplg.getText().equalsIgnoreCase(plg[j].getNamaPlgn())){
DefaultTableModel modelplg = (DefaultTableModel) jTable4.getModel();
modelplg.removeRow(j);
plg[j].setIDPlgn(null);
plg[j].setNamaPlgn(null);
plg[j].setAlamat(null);
plg[j].setNoTelp(null);
for (int k = j; k < 4; k++) {
if(plg[k+1] !=null){
plg[k].setIDPlgn(plg[k+1].getIDPlgn());
plg[k].setNamaPlgn(plg[k+1].getNamaPlgn());
plg[k].setAlamat(plg[k+1].getAlamat());
plg[k].setNoTelp(plg[k+1].getNoTelp());
}
}
isi = false;
JOptionPane.showMessageDialog(frame, "Data Pelanggan Berhasil Dihapus!");
}
else JOptionPane.showMessageDialog(frame, "Nama Pelanggan Tidak Ditemukan!");
}
else JOptionPane.showMessageDialog(frame, "ID Pelanggan Tidak Ditemukan!");
};
}
idplg.setText("");
namaplg.setText("");
alamat.setText("");
nomer.setText("");
}
private void namabrgblActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void namaplgblActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void idbrgActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void hapusbrgActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int j=0;
isi = true;
int hs = JOptionPane.showConfirmDialog(frame, "Hapus Data Barang?");
if(hs==JOptionPane.YES_OPTION){
while(j<5 && isi == true){
if(idbrg.getText().equalsIgnoreCase(brg[j].getIDBrg())){
if(namabrg.getText().equalsIgnoreCase(brg[j].getNamaBrg())){
DefaultTableModel modelbrg = (DefaultTableModel) jTable3.getModel();
modelbrg.removeRow(j);
brg[j].setIDBrg(null);
brg[j].setNamaBrg(null);
brg[j].setHarga(0);
brg[j].setStock(0);
for (int k = j; k < 4; k++) {
if(brg[k+1] !=null){
brg[k].setIDBrg(brg[k+1].getIDBrg());
brg[k].setNamaBrg(brg[k+1].getNamaBrg());
brg[k].setHarga(brg[k+1].getHarga());
brg[k].setStock(brg[k+1].getStock());
}
}
isi = false;
JOptionPane.showMessageDialog(frame, "Data Barang Berhasil Dihapus!");
}
else JOptionPane.showMessageDialog(frame, "Nama Barang Tidak Ditemukan!");
}
else JOptionPane.showMessageDialog(frame, "ID Barang Tidak Ditemukan!");
};
}
idbrg.setText("");
namabrg.setText("");
hrgbrg.setText("");
stckbrg.setText("");
}
private void tambahplgActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
isi = false; sama=false;
i=0; byte j=0;
String idp = idplg.getText();
String nameplg = namaplg.getText();
String almt = alamat.getText();
String no = nomer.getText();
DefaultTableModel modelplg = (DefaultTableModel) jTable4.getModel();
while(j<modelplg.getRowCount() && sama==false){
if(idp.equalsIgnoreCase(plg[j].getIDPlgn())) {
sama = true;
JOptionPane.showMessageDialog(frame, "Data Pelanggan Sudah Ada!");
}
else j++;
}
while(i<10 && isi == false && sama==false){
if(plg[i] == null){
plg[i] = new cPelanggan(idp, nameplg, almt, no);
row[i][0] = idp;
row[i][1] = nameplg;
row[i][2] = almt;
row[i][3] = no;
modelplg.addRow(row[i]);
isi = true;
JOptionPane.showMessageDialog(frame, "Data Pelanggan Berhasil Ditambahkan!");
}
else i++;
};
if(i>5) JOptionPane.showMessageDialog(frame, "Daftar Barang Telah Penuh!");
idplg.setText("");
namaplg.setText("");
alamat.setText("");
nomer.setText("");
}
private void beliActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
byte j =0, k=0;
boolean ketemubrg = false, ketemuplg = false;
DefaultTableModel modelbrg = (DefaultTableModel) jTable3.getModel();
while(j<5 && ketemuplg == false){
if(idplgbl.getText().equalsIgnoreCase(plg[j].getIDPlgn()) && namaplgbl.getText().equalsIgnoreCase(plg[j].getNamaPlgn())){
ketemuplg = true;
}
else j++;
}
if(ketemuplg==false) JOptionPane.showMessageDialog(frame, "Data Pelanggan Tidak Ditemukan!");
else if(ketemuplg==true){
while(k<5 && ketemubrg ==false){
if(idbrgbl.getText().equalsIgnoreCase(brg[k].getIDBrg()) && namabrgbl.getText().equalsIgnoreCase(brg[k].getNamaBrg())){
ketemubrg=true;
int jml = (Integer) jmlhbeli.getValue();
int total = jml*brg[k].getHarga();
ttlpemb.setText("Rp"+total);
int stockskrg = brg[k].getStock() - jml;
brg[k].setStock(stockskrg);
modelbrg.setValueAt(stockskrg, k, 3);
}
else k++;
}
if(ketemubrg==false) JOptionPane.showMessageDialog(frame, "Data Barang Tidak Ditemukan!");
}
}
/**
* @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(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.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 NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField alamat;
private javax.swing.JButton beli;
private javax.swing.JButton hapusbrg;
private javax.swing.JButton hapusplg;
private javax.swing.JTextField hrgbrg;
private javax.swing.JTextField idbrg;
private javax.swing.JTextField idbrgbl;
private javax.swing.JTextField idplg;
private javax.swing.JTextField idplgbl;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
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 jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel5;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTable jTable3;
private javax.swing.JTable jTable4;
private javax.swing.JSpinner jmlhbeli;
private javax.swing.JTextField namabrg;
private javax.swing.JTextField namabrgbl;
private javax.swing.JTextField namaplg;
private javax.swing.JTextField namaplgbl;
private javax.swing.JTextField nomer;
private javax.swing.JTextField stckbrg;
private javax.swing.JButton tambahbrg;
private javax.swing.JButton tambahplg;
private javax.swing.JTextArea ttlpemb;
// End of variables declaration
}
2 Comments
well done :)
ReplyDeleteTerima kasih banyak, Pak :)
Delete