/*
* formBarang.java
*
* Created on April 8, 2009, 4:04 AM
*/
import javax.swing.*;
import java.sql.*;
/**
*
* @author rizal
*/
public class formBarang extends javax.swing.JFrame {
/** Creates new form formBarang */
public formBarang() {
initComponents();
try{
Class.forName("com.mysql.jdbc.Driver");
String connectionURL = "jdbc:mysql://localhost:3306/pibj";
Connection con = DriverManager.getConnection(connectionURL,"root", "");
state = con.createStatement();
rs = state.executeQuery("select * from barang");
rs.next();
template();
}
catch (SQLException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroupJenisPenjualan = new javax.swing.ButtonGroup();
labelJudul = new javax.swing.JLabel();
labelKodeBarang = new javax.swing.JLabel();
labelNamaBarang = new javax.swing.JLabel();
labelHarga = new javax.swing.JLabel();
labelJenisBarang = new javax.swing.JLabel();
labelJenisPenjualan = new javax.swing.JLabel();
textKodeBarang = new javax.swing.JTextField();
textNamaBarang = new javax.swing.JTextField();
textHarga = new javax.swing.JTextField();
comboJenisBarang = new javax.swing.JComboBox();
radioBolehKredit = new javax.swing.JRadioButton();
radioTidakBolehKredit = new javax.swing.JRadioButton();
buttonFirst = new javax.swing.JButton();
buttonAdd = new javax.swing.JButton();
buttonPrev = new javax.swing.JButton();
buttonNext = new javax.swing.JButton();
buttonLast = new javax.swing.JButton();
buttonEdit = new javax.swing.JButton();
buttonDel = new javax.swing.JButton();
buttonSimpan = new javax.swing.JButton();
buttonBatal = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Masrizal Frisnanto - 5206100019");
labelJudul.setFont(new java.awt.Font("Tahoma", 0, 18));
labelJudul.setText("Form Barang");
labelKodeBarang.setText("Kode Barang");
labelNamaBarang.setText("Nama Barang");
labelHarga.setText("Harga");
labelJenisBarang.setText("Jenis Barang");
labelJenisPenjualan.setText("Jenis Penjualan");
textHarga.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
textHargaActionPerformed(evt);
}
});
comboJenisBarang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Komputer", "Majalah", "Elektronik" }));
comboJenisBarang.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboJenisBarangActionPerformed(evt);
}
});
buttonGroupJenisPenjualan.add(radioBolehKredit);
radioBolehKredit.setText("Boleh Kredit");
buttonGroupJenisPenjualan.add(radioTidakBolehKredit);
radioTidakBolehKredit.setText("Tidak Boleh Kredit");
buttonFirst.setText("First");
buttonFirst.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonFirstActionPerformed(evt);
}
});
buttonAdd.setText("Add");
buttonAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAddActionPerformed(evt);
}
});
buttonPrev.setText("Previous");
buttonPrev.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonPrevActionPerformed(evt);
}
});
buttonNext.setText("Next");
buttonNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonNextActionPerformed(evt);
}
});
buttonLast.setText("Last");
buttonLast.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonLastActionPerformed(evt);
}
});
buttonEdit.setText("Edit");
buttonDel.setText("Delete");
buttonDel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonDelActionPerformed(evt);
}
});
buttonSimpan.setText("SIMPAN");
buttonSimpan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSimpanActionPerformed(evt);
}
});
buttonBatal.setText("BATAL");
buttonBatal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonBatalActionPerformed(evt);
}
});
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.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(labelJudul)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(labelKodeBarang)
.addComponent(labelNamaBarang)
.addComponent(labelHarga)
.addComponent(labelJenisBarang)
.addComponent(labelJenisPenjualan))
.addGap(52, 52, 52)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(radioTidakBolehKredit)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(radioBolehKredit)
.addComponent(comboJenisBarang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textKodeBarang, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
.addComponent(textNamaBarang)
.addComponent(textHarga))
.addGap(58, 58, 58)