void updateJmlhSks() { int total = 0; for (Mk mk : mk2List) { total = total + mk.getSks(); } txtJumlahKrs.setText(String.valueOf(total)); }
void isitabelKrs() { Object data[][] = new Object[mk2List.size()][4]; int x = 0; for (Mk mk : mk2List) { data[x][0] = mk.getKd_mk(); data[x][1] = mk.getMk(); data[x][2] = mk.getSks(); data[x][3] = mk.getJurusan(); x++; } String[] judul = {"Kode", "Nama", "Sks", "Jurusan"}; tableAmbil.setModel(new DefaultTableModel(data, judul)); jScrollPane1.setViewportView(tableAmbil); }
boolean bolehTidak(Mk mk) { boolean status = true; for (int a = 0; a < mk2List.size(); a++) { if (mk2List.get(a).getKd_mk().equals(mk.getKd_mk())) { status = false; break; } else { status = true; } } return status; }
private void ambilButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_ambilButtonActionPerformed try { // TODO add your handling code here: Mk kd = mkList.get(tableKrsJur.getSelectedRow()); int cadangan = kd.getSks(); if (bolehTidak(kd)) { if ((Integer.valueOf(txtJumlahKrs.getText()) + cadangan) <= 24) { mk2List.add(kd); this.isitabelKrs(); this.updateJmlhSks(); } else { JOptionPane.showMessageDialog(this, "SKS melebihi kuwota"); } } else { JOptionPane.showMessageDialog(this, "matakuliah sudah diambil"); } } catch (ArrayIndexOutOfBoundsException ex) { Logger.getLogger(MenuUtama.class.getName()).log(Level.SEVERE, null, ex); } } // GEN-LAST:event_ambilButtonActionPerformed