1.jalankan aplikasi program netbeans
setelah menjalankan kelik file >new project>kelick next>membuat nama project>klik Finish
2. cara connection database ke netbeans
a. services databases klik kanan new connection
b. driver pilih MySQL ( connector / J driver) next
c. database : isi nama databases yg sudah di buat test connection
d. finish
e. di projek klik kanan new pilih master detail simple from f. package isi tempat yg di inginkan next next finish
oke saya akan menampilkan hasil nya screenshots project saya yaitu membuat tiket berenang
INI SCRIPT
NYA
private void
closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
//
TODO add your handling code here:
{
System.exit(0);
}
}
private void
NewButtonActionPerformed(java.awt.event.ActionEvent evt) {
//
TODO add your handling code here:
tiketberenang.PenjualanTiket p = new tiketberenang.PenjualanTiket();
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) {
//
TODO add your handling code here:
try {
entityManager.getTransaction().commit();
entityManager.getTransaction().begin();
}
catch (RollbackException rex) {
rex.printStackTrace();
entityManager.getTransaction().begin();
List<tiketberenang.PenjualanTiket> merged = new
ArrayList<tiketberenang.PenjualanTiket >(list.size());
for (tiketberenang.PenjualanTiket p : list) {
merged.add(entityManager.merge(p));
}
list.clear();
list.addAll(merged);
}
}
private void
hitungButtonActionPerformed(java.awt.event.ActionEvent evt) {
//
TODO add your handling code here:
float
jumlahtiket=Float.parseFloat(jumlahtiketField.getText());
float
hargatiket=Float.parseFloat(hargatiketField.getText());
float
hargatotal=jumlahtiket*hargatiket;
hargatotalField.setText(""+hargatotal);
}
private void
refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
//
TODO add your handling code here:
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< tiketberenang.PenjualanTiket > toRemove = new ArrayList<
tiketberenang.PenjualanTiket >(selected.length);
for (int idx = 0; idx <
selected.length; idx++) {
tiketberenang.PenjualanTiket t =
list.get(masterTable.convertRowIndexToModel(selected[idx]));
toRemove.add(t);
entityManager.remove(t);
}
list.removeAll(toRemove);
}
Tidak ada komentar:
Posting Komentar