List of usage examples for javax.swing.table DefaultTableModel removeRow
public void removeRow(int row)
row
from the model. From source file:com.yosanai.java.swing.config.ConfigPanel.java
private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnRemoveActionPerformed int row = tblConfig.getSelectedRow(); DefaultTableModel model = (DefaultTableModel) tblConfig.getModel(); if (-1 < row) { model.removeRow(row); }// w ww . j a v a 2s .c om }
From source file:com.yosanai.java.swing.config.ConfigPanel.java
public void loadConfig(Map<String, String> config) { DefaultTableModel model = (DefaultTableModel) tblConfig.getModel(); while (0 < model.getRowCount()) { model.removeRow(0); }/*from w ww .ja va 2 s . c o m*/ for (String key : config.keySet()) { model.addRow(new Object[] { key, (null == config.get(key) ? "" : config.get(key)) }); } }
From source file:com.yosanai.java.swing.config.FileBackedConfigDialog.java
protected void load(String... keys) { DefaultTableModel model = (DefaultTableModel) tblConfig.getModel(); while (0 < model.getRowCount()) { model.removeRow(0); }/*from w w w.ja v a 2 s . com*/ for (String key : keys) { model.addRow(new Object[] { key, configuration.getString(key, "") }); } }
From source file:com.willwinder.universalgcodesender.uielements.panels.ControllerProcessorSettingsPanel.java
private void removeSelectedPatternRemover() { int[] rows = customRemoverTable.getSelectedRows(); Arrays.sort(rows);/*from ww w .ja v a 2 s . c o m*/ DefaultTableModel model = (DefaultTableModel) this.customRemoverTable.getModel(); for (int i = rows.length; i > 0; i--) { int row = rows[i - 1]; model.removeRow(row); } }
From source file:cz.moz.ctmanager.main.MainAppFrame.java
private void removeContactButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeContactButtonActionPerformed int selectedRow = contactTable.getSelectedRow(); if (selectedRow == -1) { JOptionPane.showMessageDialog(this, "Nothing Selected", "Error Message", JOptionPane.ERROR_MESSAGE); } else {// ww w .jav a 2s.co m Object[] options = { "Are you Sure?" }; int choice = JOptionPane.showConfirmDialog(this, options, "Are you Sure", 2); if (choice == 0) { DefaultTableModel newTableModel = (DefaultTableModel) contactTable.getModel(); int selectedContactID = (int) contactTable.getValueAt(contactTable.getSelectedRow(), 0); newTableModel.removeRow(selectedRow); emailsDao.removeAll(selectedContactID); phonesDao.removeAll(selectedContactID); contactsDao.removeContact(selectedContactID); } } }
From source file:userinterface.AdministratorWorkArea.TopMedicineJPanel.java
/** * Creates new form TopMedicineJPanel/*w ww. j a va2 s .c om*/ */ public TopMedicineJPanel(JPanel upc, Enterprise e, UserAccount ua) { initComponents(); userProcessContainer = upc; userAccount = ua; enterprise = e; for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof AdminOrganization) { org = organization; break; } } if (org != null) { String maxMed = null; int maxQaunt = 0; for (WorkRequest request : org.getWorkQueue().getWorkRequestList()) { if (request instanceof MedicineWorkRequest) { int quant = ((MedicineWorkRequest) request).getQuantityOrdered(); if (quant > maxQaunt) { maxQaunt = quant; maxMed = ((MedicineWorkRequest) request).getMedicineName(); } } } DefaultTableModel dtm = (DefaultTableModel) productTable.getModel(); int rowcount = productTable.getRowCount(); for (int i = rowcount - 1; i >= 0; i--) { dtm.removeRow(i); } Object row[] = new Object[2]; row[0] = maxMed == null ? "No Medicines Ordered Yet" : maxMed; row[1] = maxQaunt == 0 ? "No Medicines Ordered Yet" : maxQaunt; dtm.addRow(row); } }
From source file:fitmon.WorkoutLog.java
private void removeItem(java.awt.event.MouseEvent evt) { if (evt.getClickCount() == 1) { JTable target = (JTable) evt.getSource(); int row = target.getSelectedRow(); int column = target.getSelectedColumn(); String selectedwkt = (String) target.getValueAt(row, 0); //int index = selectedwkt.indexOf("--"); // String foodName = selectedFood.substring(0, index); //int calorie = selectedFood.substring(index+2); if (target.getColumnName(target.getSelectedColumn()).equals("Edit")) { DefaultTableModel model = (DefaultTableModel) tab.getModel(); model.removeRow(row); for (int i = 0; i < wkt.size(); i++) { if (wkt.get(i).getWorkout().equals(selectedwkt)) //&& wkt.get(i).getCal().equals(calorie)) {/*ww w.j a v a 2 s . c o m*/ wkt.remove(i); break; } } } // do some action if appropriate column } // TODO add your handling code here: }
From source file:graph.plotter.PieMenu.java
/** * This method works for deleting a data entry * @param evt /*from w w w .j av a2 s.c o m*/ */ private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed DefaultTableModel model = (DefaultTableModel) Table.getModel(); model.removeRow(Table.getSelectedRow()); cnt--; }
From source file:graph.plotter.BarMenu.java
/** * This method works for deleting a data entry * @param evt /*w w w . j a v a 2s .c o m*/ */ private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed DefaultTableModel model = (DefaultTableModel) Table.getModel(); model.removeRow(Table.getSelectedRow()); count--; }
From source file:userinterface.AdministratorWorkArea.PopularDoctorJPanel.java
public void populateTable() { int max1 = Integer.MIN_VALUE; int max2 = Integer.MIN_VALUE; int max3 = Integer.MIN_VALUE; for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof DoctorOrganization) { docOrg = organization;// w ww . j a v a 2s. c o m break; } } if (docOrg != null) { for (Employee doctor : docOrg.getEmployeeDirectory().getEmployeeList()) { if (doctor.getPatientCount() > max1) { max3 = max2; max2 = max1; max1 = doctor.getPatientCount(); doc3 = doc2; doc2 = doc1; doc1 = doctor; } else if (doctor.getPatientCount() > max2 && doctor.getPatientCount() <= max1) { max3 = max2; max2 = doctor.getPatientCount(); doc3 = doc2; doc2 = doctor; } else if (doctor.getPatientCount() <= max2 && doctor.getPatientCount() > max3) { max3 = doctor.getPatientCount(); doc3 = doctor; } } if (doc3 != null && doc2 != null && doc1 != null) { topDocList.add(doc1); topDocList.add(doc2); topDocList.add(doc3); } else if (doc2 != null && doc1 != null) { topDocList.add(doc1); topDocList.add(doc2); } else if (doc1 != null) { topDocList.add(doc1); } // topDocList.add(doc1); // topDocList.add(doc2); // topDocList.add(doc3); } DefaultTableModel dtm = (DefaultTableModel) doctorTable.getModel(); int rowcount = doctorTable.getRowCount(); for (int i = rowcount - 1; i >= 0; i--) { dtm.removeRow(i); } if (topDocList != null) { for (Employee doctor : topDocList) { Object row[] = new Object[2]; row[0] = doctor == null ? "No Doctors in the Organization" : doctor; row[1] = doctor == null ? " " : doctor.getPatientCount(); dtm.addRow(row); } } else { return; } }