예제 #1
0
 private void LoadRows() {
   mMember member = new mMember();
   List CollectionOfMember = member.FetchRows();
   ListIterator lst = CollectionOfMember.listIterator();
   DefaultTableModel tblModel = (DefaultTableModel) jTabMember.getModel();
   while (lst.hasNext()) {
     mMember item = (mMember) lst.next();
     tblModel.addRow(
         new Object[] {
           item.getId(),
           item.getNama(),
           item.getAlamat(),
           item.getJenisPengenal(),
           item.getNoPengenal(),
           item.getKontak(),
           item.getTglDaftar()
         });
   }
 }
예제 #2
0
 private void CopyObjectToModel() {
   _member.setId(txtId.getText());
   _member.setNama(txtNama.getText());
   _member.setAlamat(txtAlamat.getText());
   _member.setJenisPengenal(mMember.EnumJenisPengenal.values()[cmbJenis.getSelectedIndex()]);
   _member.setNoPengenal(txtPengenal.getText());
   _member.setKontak(txtKontak.getText());
   _member.setTglDaftar(skg);
 }
예제 #3
0
  private void btnDeleteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeleteActionPerformed
    int result =
        JOptionPane.showConfirmDialog(
            null, "Anda yakin ingin menghapus data ini?", "Konfirmasi", JOptionPane.YES_NO_OPTION);

    if (result == JOptionPane.YES_OPTION) {
      this.CopyObjectToModel();
      _member.EraseRow();
      DefaultTableModel tblModel = (DefaultTableModel) jTabMember.getModel();
      tblModel.removeRow(jTabMember.convertColumnIndexToModel(jTabMember.getSelectedRow()));
    }
  } // GEN-LAST:event_btnDeleteActionPerformed
예제 #4
0
  private boolean SaveRow() {
    boolean result = false;

    this.CopyObjectToModel();
    if (_member.MergeRow()) {
      DefaultTableModel tblModel = (DefaultTableModel) jTabMember.getModel();
      if (_isNew) {
        tblModel.addRow(
            new Object[] {
              _member.getId(),
              _member.getNama(),
              _member.getAlamat(),
              _member.getJenisPengenal(),
              _member.getNoPengenal(),
              _member.getKontak(),
              skg.toString()
            });
        cUtils.ClearObjInput(
            new Object[] {txtId, txtNama, txtAlamat, cmbJenis, txtPengenal, txtKontak});
      } else {
        int rowPosition = jTabMember.convertRowIndexToModel(jTabMember.getSelectedRow());
        tblModel.setValueAt(_member.getId(), rowPosition, 0);
        tblModel.setValueAt(_member.getNama(), rowPosition, 1);
        tblModel.setValueAt(_member.getAlamat(), rowPosition, 2);
        tblModel.setValueAt(_member.getJenisPengenal(), rowPosition, 3);
        tblModel.setValueAt(_member.getNoPengenal(), rowPosition, 4);
        tblModel.setValueAt(_member.getKontak(), rowPosition, 5);
        tblModel.setValueAt(skg, rowPosition, 6);
      }
      result = true;
    }
    return result;
  }