Program Implementasi Passing Grade ke Java (Data Base)
- Dibawah ini adalah Table DataBase Yang dibuat di PHPMyAdmin.
- Dibawah ini Form hasil dari PHPMyAdmin yang langsung jadi diNetbeans. Setelah memasukkan link dari PHPMyAdmin.
#Berikut ini coding yang digunakan dan langsung ada pada netbeans, Karena kita sudah membuat form di PHPMyAdmin
/*
* 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 dbpassinggrade_161011700054;
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 INTELAMD
*/
public class DBPassingGrade extends JPanel {
public DBPassingGrade() {
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("DBPassingGrade_161011700054?zeroDateTimeBehavior=convertToNullPU").createEntityManager();
query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT d FROM Dbpassinggrade161011700054 d");
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();
idLabel = new javax.swing.JLabel();
namaCalonPegawaiLabel = new javax.swing.JLabel();
materiTestLabel = new javax.swing.JLabel();
nilaiBenarLabel = new javax.swing.JLabel();
nilaiSalahLabel = new javax.swing.JLabel();
nilaiKosongLabel = new javax.swing.JLabel();
jumlahNilaiLabel = new javax.swing.JLabel();
passingGradeLabel = new javax.swing.JLabel();
idField = new javax.swing.JTextField();
namaCalonPegawaiField = new javax.swing.JTextField();
materiTestField = new javax.swing.JTextField();
nilaiBenarField = new javax.swing.JTextField();
nilaiSalahField = new javax.swing.JTextField();
nilaiKosongField = new javax.swing.JTextField();
jumlahNilaiField = new javax.swing.JTextField();
passingGradeField = new javax.swing.JTextField();
saveButton = new javax.swing.JButton();
refreshButton = new javax.swing.JButton();
newButton = new javax.swing.JButton();
deleteButton = new javax.swing.JButton();
process = new javax.swing.JButton();
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("${id}"));
columnBinding.setColumnName("Id");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${namaCalonPegawai}"));
columnBinding.setColumnName("Nama Calon Pegawai");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${materiTest}"));
columnBinding.setColumnName("Materi Test");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nilaiBenar}"));
columnBinding.setColumnName("Nilai Benar");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nilaiSalah}"));
columnBinding.setColumnName("Nilai Salah");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nilaiKosong}"));
columnBinding.setColumnName("Nilai Kosong");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${jumlahNilai}"));
columnBinding.setColumnName("Jumlah Nilai");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${passingGrade}"));
columnBinding.setColumnName("Passing Grade");
columnBinding.setColumnClass(Integer.class);
bindingGroup.addBinding(jTableBinding);
masterScrollPane.setViewportView(masterTable);
idLabel.setText("Id:");
namaCalonPegawaiLabel.setText("Nama Calon Pegawai:");
materiTestLabel.setText("Materi Test:");
nilaiBenarLabel.setText("Nilai Benar:");
nilaiSalahLabel.setText("Nilai Salah:");
nilaiKosongLabel.setText("Nilai Kosong:");
jumlahNilaiLabel.setText("Jumlah Nilai:");
passingGradeLabel.setText("Passing Grade:");
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.id}"), idField, 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}"), idField, 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.namaCalonPegawai}"), namaCalonPegawaiField, 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}"), namaCalonPegawaiField, 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.materiTest}"), materiTestField, 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}"), materiTestField, 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.nilaiBenar}"), nilaiBenarField, 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}"), nilaiBenarField, 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.nilaiSalah}"), nilaiSalahField, 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}"), nilaiSalahField, 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.nilaiKosong}"), nilaiKosongField, 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}"), nilaiKosongField, 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.jumlahNilai}"), jumlahNilaiField, 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}"), jumlahNilaiField, 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.passingGrade}"), passingGradeField, 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}"), passingGradeField, 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);
process.setText("Process");
process.addActionListener(formListener);
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(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(process)
.addGap(18, 18, 18)
.addComponent(newButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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(idLabel)
.addComponent(namaCalonPegawaiLabel)
.addComponent(materiTestLabel)
.addComponent(nilaiBenarLabel)
.addComponent(nilaiSalahLabel)
.addComponent(nilaiKosongLabel)
.addComponent(jumlahNilaiLabel)
.addComponent(passingGradeLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(idField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(namaCalonPegawaiField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(materiTestField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(nilaiBenarField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(nilaiSalahField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(nilaiKosongField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(jumlahNilaiField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(passingGradeField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)))
.addComponent(masterScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
.addContainerGap())
);
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.DEFAULT_SIZE, 130, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(idLabel)
.addComponent(idField, 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(namaCalonPegawaiLabel)
.addComponent(namaCalonPegawaiField, 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(materiTestLabel)
.addComponent(materiTestField, 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(nilaiBenarLabel)
.addComponent(nilaiBenarField, 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(nilaiSalahLabel)
.addComponent(nilaiSalahField, 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(nilaiKosongLabel)
.addComponent(nilaiKosongField, 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(jumlahNilaiLabel)
.addComponent(jumlahNilaiField, 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(passingGradeLabel)
.addComponent(passingGradeField, 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(saveButton)
.addComponent(refreshButton)
.addComponent(deleteButton)
.addComponent(newButton)
.addComponent(process))
.addContainerGap())
);
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() == saveButton) {
DBPassingGrade.this.saveButtonActionPerformed(evt);
}
else if (evt.getSource() == refreshButton) {
DBPassingGrade.this.refreshButtonActionPerformed(evt);
}
else if (evt.getSource() == newButton) {
DBPassingGrade.this.newButtonActionPerformed(evt);
}
else if (evt.getSource() == deleteButton) {
DBPassingGrade.this.deleteButtonActionPerformed(evt);
}
else if (evt.getSource() == process) {
DBPassingGrade.this.processActionPerformed(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<dbpassinggrade_161011700054.Dbpassinggrade161011700054> toRemove = new ArrayList<dbpassinggrade_161011700054.Dbpassinggrade161011700054>(selected.length);
for (int idx = 0; idx < selected.length; idx++) {
dbpassinggrade_161011700054.Dbpassinggrade161011700054 d = list.get(masterTable.convertRowIndexToModel(selected[idx]));
toRemove.add(d);
entityManager.remove(d);
}
list.removeAll(toRemove);
}
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {
dbpassinggrade_161011700054.Dbpassinggrade161011700054 d = new dbpassinggrade_161011700054.Dbpassinggrade161011700054();
entityManager.persist(d);
list.add(d);
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<dbpassinggrade_161011700054.Dbpassinggrade161011700054> merged = new ArrayList<dbpassinggrade_161011700054.Dbpassinggrade161011700054>(list.size());
for (dbpassinggrade_161011700054.Dbpassinggrade161011700054 d : list) {
merged.add(entityManager.merge(d));
}
list.clear();
list.addAll(merged);
}
}
// Variables declaration - do not modify
private javax.swing.JButton deleteButton;
private javax.persistence.EntityManager entityManager;
private javax.swing.JTextField idField;
private javax.swing.JLabel idLabel;
private javax.swing.JTextField jumlahNilaiField;
private javax.swing.JLabel jumlahNilaiLabel;
private java.util.List<dbpassinggrade_161011700054.Dbpassinggrade161011700054> list;
private javax.swing.JScrollPane masterScrollPane;
private javax.swing.JTable masterTable;
private javax.swing.JTextField materiTestField;
private javax.swing.JLabel materiTestLabel;
private javax.swing.JTextField namaCalonPegawaiField;
private javax.swing.JLabel namaCalonPegawaiLabel;
private javax.swing.JButton newButton;
private javax.swing.JTextField nilaiBenarField;
private javax.swing.JLabel nilaiBenarLabel;
private javax.swing.JTextField nilaiKosongField;
private javax.swing.JLabel nilaiKosongLabel;
private javax.swing.JTextField nilaiSalahField;
private javax.swing.JLabel nilaiSalahLabel;
private javax.swing.JTextField passingGradeField;
private javax.swing.JLabel passingGradeLabel;
private javax.swing.JButton process;
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(DBPassingGrade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DBPassingGrade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DBPassingGrade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DBPassingGrade.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 DBPassingGrade());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
});
}
}
* 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 dbpassinggrade_161011700054;
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 INTELAMD
*/
public class DBPassingGrade extends JPanel {
public DBPassingGrade() {
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("DBPassingGrade_161011700054?zeroDateTimeBehavior=convertToNullPU").createEntityManager();
query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT d FROM Dbpassinggrade161011700054 d");
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();
idLabel = new javax.swing.JLabel();
namaCalonPegawaiLabel = new javax.swing.JLabel();
materiTestLabel = new javax.swing.JLabel();
nilaiBenarLabel = new javax.swing.JLabel();
nilaiSalahLabel = new javax.swing.JLabel();
nilaiKosongLabel = new javax.swing.JLabel();
jumlahNilaiLabel = new javax.swing.JLabel();
passingGradeLabel = new javax.swing.JLabel();
idField = new javax.swing.JTextField();
namaCalonPegawaiField = new javax.swing.JTextField();
materiTestField = new javax.swing.JTextField();
nilaiBenarField = new javax.swing.JTextField();
nilaiSalahField = new javax.swing.JTextField();
nilaiKosongField = new javax.swing.JTextField();
jumlahNilaiField = new javax.swing.JTextField();
passingGradeField = new javax.swing.JTextField();
saveButton = new javax.swing.JButton();
refreshButton = new javax.swing.JButton();
newButton = new javax.swing.JButton();
deleteButton = new javax.swing.JButton();
process = new javax.swing.JButton();
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("${id}"));
columnBinding.setColumnName("Id");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${namaCalonPegawai}"));
columnBinding.setColumnName("Nama Calon Pegawai");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${materiTest}"));
columnBinding.setColumnName("Materi Test");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nilaiBenar}"));
columnBinding.setColumnName("Nilai Benar");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nilaiSalah}"));
columnBinding.setColumnName("Nilai Salah");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nilaiKosong}"));
columnBinding.setColumnName("Nilai Kosong");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${jumlahNilai}"));
columnBinding.setColumnName("Jumlah Nilai");
columnBinding.setColumnClass(Integer.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${passingGrade}"));
columnBinding.setColumnName("Passing Grade");
columnBinding.setColumnClass(Integer.class);
bindingGroup.addBinding(jTableBinding);
masterScrollPane.setViewportView(masterTable);
idLabel.setText("Id:");
namaCalonPegawaiLabel.setText("Nama Calon Pegawai:");
materiTestLabel.setText("Materi Test:");
nilaiBenarLabel.setText("Nilai Benar:");
nilaiSalahLabel.setText("Nilai Salah:");
nilaiKosongLabel.setText("Nilai Kosong:");
jumlahNilaiLabel.setText("Jumlah Nilai:");
passingGradeLabel.setText("Passing Grade:");
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.id}"), idField, 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}"), idField, 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.namaCalonPegawai}"), namaCalonPegawaiField, 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}"), namaCalonPegawaiField, 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.materiTest}"), materiTestField, 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}"), materiTestField, 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.nilaiBenar}"), nilaiBenarField, 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}"), nilaiBenarField, 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.nilaiSalah}"), nilaiSalahField, 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}"), nilaiSalahField, 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.nilaiKosong}"), nilaiKosongField, 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}"), nilaiKosongField, 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.jumlahNilai}"), jumlahNilaiField, 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}"), jumlahNilaiField, 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.passingGrade}"), passingGradeField, 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}"), passingGradeField, 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);
process.setText("Process");
process.addActionListener(formListener);
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(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(process)
.addGap(18, 18, 18)
.addComponent(newButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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(idLabel)
.addComponent(namaCalonPegawaiLabel)
.addComponent(materiTestLabel)
.addComponent(nilaiBenarLabel)
.addComponent(nilaiSalahLabel)
.addComponent(nilaiKosongLabel)
.addComponent(jumlahNilaiLabel)
.addComponent(passingGradeLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(idField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(namaCalonPegawaiField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(materiTestField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(nilaiBenarField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(nilaiSalahField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(nilaiKosongField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(jumlahNilaiField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
.addComponent(passingGradeField, javax.swing.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)))
.addComponent(masterScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
.addContainerGap())
);
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.DEFAULT_SIZE, 130, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(idLabel)
.addComponent(idField, 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(namaCalonPegawaiLabel)
.addComponent(namaCalonPegawaiField, 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(materiTestLabel)
.addComponent(materiTestField, 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(nilaiBenarLabel)
.addComponent(nilaiBenarField, 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(nilaiSalahLabel)
.addComponent(nilaiSalahField, 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(nilaiKosongLabel)
.addComponent(nilaiKosongField, 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(jumlahNilaiLabel)
.addComponent(jumlahNilaiField, 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(passingGradeLabel)
.addComponent(passingGradeField, 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(saveButton)
.addComponent(refreshButton)
.addComponent(deleteButton)
.addComponent(newButton)
.addComponent(process))
.addContainerGap())
);
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() == saveButton) {
DBPassingGrade.this.saveButtonActionPerformed(evt);
}
else if (evt.getSource() == refreshButton) {
DBPassingGrade.this.refreshButtonActionPerformed(evt);
}
else if (evt.getSource() == newButton) {
DBPassingGrade.this.newButtonActionPerformed(evt);
}
else if (evt.getSource() == deleteButton) {
DBPassingGrade.this.deleteButtonActionPerformed(evt);
}
else if (evt.getSource() == process) {
DBPassingGrade.this.processActionPerformed(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<dbpassinggrade_161011700054.Dbpassinggrade161011700054> toRemove = new ArrayList<dbpassinggrade_161011700054.Dbpassinggrade161011700054>(selected.length);
for (int idx = 0; idx < selected.length; idx++) {
dbpassinggrade_161011700054.Dbpassinggrade161011700054 d = list.get(masterTable.convertRowIndexToModel(selected[idx]));
toRemove.add(d);
entityManager.remove(d);
}
list.removeAll(toRemove);
}
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {
dbpassinggrade_161011700054.Dbpassinggrade161011700054 d = new dbpassinggrade_161011700054.Dbpassinggrade161011700054();
entityManager.persist(d);
list.add(d);
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<dbpassinggrade_161011700054.Dbpassinggrade161011700054> merged = new ArrayList<dbpassinggrade_161011700054.Dbpassinggrade161011700054>(list.size());
for (dbpassinggrade_161011700054.Dbpassinggrade161011700054 d : list) {
merged.add(entityManager.merge(d));
}
list.clear();
list.addAll(merged);
}
}
// Variables declaration - do not modify
private javax.swing.JButton deleteButton;
private javax.persistence.EntityManager entityManager;
private javax.swing.JTextField idField;
private javax.swing.JLabel idLabel;
private javax.swing.JTextField jumlahNilaiField;
private javax.swing.JLabel jumlahNilaiLabel;
private java.util.List<dbpassinggrade_161011700054.Dbpassinggrade161011700054> list;
private javax.swing.JScrollPane masterScrollPane;
private javax.swing.JTable masterTable;
private javax.swing.JTextField materiTestField;
private javax.swing.JLabel materiTestLabel;
private javax.swing.JTextField namaCalonPegawaiField;
private javax.swing.JLabel namaCalonPegawaiLabel;
private javax.swing.JButton newButton;
private javax.swing.JTextField nilaiBenarField;
private javax.swing.JLabel nilaiBenarLabel;
private javax.swing.JTextField nilaiKosongField;
private javax.swing.JLabel nilaiKosongLabel;
private javax.swing.JTextField nilaiSalahField;
private javax.swing.JLabel nilaiSalahLabel;
private javax.swing.JTextField passingGradeField;
private javax.swing.JLabel passingGradeLabel;
private javax.swing.JButton process;
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(DBPassingGrade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DBPassingGrade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DBPassingGrade.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DBPassingGrade.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 DBPassingGrade());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
});
}
}
#Dibawah ini code untuk Button Proses yang dibuat diNetbeans.
private void processActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int nilaiBenar=Integer.parseInt( nilaiBenarField.getText());
int nilaiSalah=Integer.parseInt( nilaiSalahField.getText());
int nilaiKosong=Integer.parseInt( nilaiKosongField.getText());
int JmlSoal=nilaiBenar+nilaiSalah+nilaiKosong;
int PassingGrade=((nilaiBenar*4)-(nilaiSalah*1))*100;
int FinalPassing=(PassingGrade)/(JmlSoal*4);
passingGradeField.setText(""+FinalPassing);
}
// TODO add your handling code here:
int nilaiBenar=Integer.parseInt( nilaiBenarField.getText());
int nilaiSalah=Integer.parseInt( nilaiSalahField.getText());
int nilaiKosong=Integer.parseInt( nilaiKosongField.getText());
int JmlSoal=nilaiBenar+nilaiSalah+nilaiKosong;
int PassingGrade=((nilaiBenar*4)-(nilaiSalah*1))*100;
int FinalPassing=(PassingGrade)/(JmlSoal*4);
passingGradeField.setText(""+FinalPassing);
}
Sekian dari saya Wassalamu'alaikum wr. wb.
Komentar
Posting Komentar