Recents in Beach

Script Menampilkan Record Data Mahasiswa Lengkap Pemrograman 5

kali ini saya akan berbagi reviews 
mengenai script dan cara menampilkan record data mahasiswa,
semoga bermanfaat ya teman... 

PEMROGRAMAN V
FORM INPUT MAHASISWA



1. Tampilan Awal form NewMasterDetailForm.java

2. Tampilan Button New untuk menambahkan data baru
 
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {                                         
        pv2.Mhs m = new pv2.Mhs();
        entityManager.persist(m);
        list.add(m);
        int row = list.size() - 1;
        masterTable.setRowSelectionInterval(row, row);
        masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
    }


3. Tampilan Button Hapus setelah data di hapus
 
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        int[] selected = masterTable.getSelectedRows();
        List<pv2.Mhs> toRemove = new ArrayList<pv2.Mhs>(selected.length);
        for (int idx = 0; idx < selected.length; idx++) {
            pv2.Mhs m = list.get(masterTable.convertRowIndexToModel(selected[idx]));
            toRemove.add(m);
            entityManager.remove(m);
        }
        list.removeAll(toRemove);
    }  

4. Tampilan Button Save untuk menyimpan data yang baru saja di tambahkan

private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           

        try {
            entityManager.getTransaction().commit();
            entityManager.getTransaction().begin();
        } catch (RollbackException rex) {
            rex.printStackTrace();
            entityManager.getTransaction().begin();
            List<pv2.Mhs> merged = new ArrayList<pv2.Mhs>(list.size());
            for (pv2.Mhs m : list) {
                merged.add(entityManager.merge(m));
            }
            list.clear();
            list.addAll(merged);
        }
    }                  
   
5. Tampilan Button 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);
    }
 
6. Tampilan Button Keluar
 
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    System.exit(0);       

Posting Komentar

0 Komentar

Disqus Shortname

designcart

Comments system

[blogger][disqus][facebook]