List of usage examples for javax.swing.table DefaultTableModel getValueAt
public Object getValueAt(int row, int column)
row
and column
. From source file:UserInterface.Supplier.SalesOverviewJPanel.java
public void populateTable() { DefaultTableModel dtm = (DefaultTableModel) performanceJTable.getModel(); dtm.setRowCount(0);/*from ww w. ja v a 2 s. c o m*/ Object[] obj = new Object[3]; ArrayList<String> temp = new ArrayList<>(); for (Order o : moc.getMoc()) { if (o.getSupplier().getCompanyName().equals(s.getCompanyName())) { for (OrderItem oi : o.getListOfItemsOrdered()) { if (!temp.contains(oi.getProduct().getTypeOfDevice())) { obj[0] = oi.getProduct().getTypeOfDevice(); obj[1] = oi.getQuantity(); obj[2] = oi.getProduct().getCost() * oi.getQuantity(); dtm.addRow(obj); temp.add(oi.getProduct().getTypeOfDevice()); } else if (temp.contains(oi.getProduct().getTypeOfDevice())) { for (int i = 0; i < dtm.getRowCount(); i++) { String prodname = (String) dtm.getValueAt(i, 0); if (prodname.equals(oi.getProduct().getTypeOfDevice())) { int q = (int) dtm.getValueAt(i, 1) + oi.getQuantity(); int sale = q * oi.getProduct().getCost(); dtm.setValueAt(q, i, 1); dtm.setValueAt(sale, i, 2); } } } } } } }
From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java
private void fwdDoctorBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fwdDoctorBtnActionPerformed int selectedRow = vitalSignjTable.getSelectedRow(); Date requestDate = new Date(); Person person = (Person) nameComboBox.getSelectedItem(); //account.getPerson().getPersonName(); String status = (String) vitalSignjTable.getValueAt(selectedRow, 6); for (Organization orgz : enterprise.getOrganizationList().getOrganizationList()) { if (orgz instanceof HospitalDoctorOrg) { for (UserAccount ua : orgz.getUserAccDir().getUserAccountList()) { account = ua;/*from w w w. ja v a 2s. c o m*/ } } } if (selectedRow >= 0) { try { if (!status.equals("Normal")) { DefaultTableModel model = (DefaultTableModel) vitalSignjTable.getModel(); Member member = (Member) model.getValueAt(selectedRow, 0); //VitalSign timestamp = (VitalSign)vitalSignjTable.getValueAt(selectedRow, 1); String message = member.getMemberName(); VitalSign vs = (VitalSign) vitalSignjTable.getValueAt(selectedRow, 1); if (vs.getAlertStatus().equals("Requested doc")) { JOptionPane.showMessageDialog(null, "Vital Sign data already sent to doctors", "WARNING", JOptionPane.WARNING_MESSAGE); return; } else if (vs.getAlertStatus().equals("Doc Reviewed") || vs.getAlertStatus().equals("sent to house")) { JOptionPane.showMessageDialog(null, "Vital Sign record already reviewed by doctor", "WARNING", JOptionPane.WARNING_MESSAGE); return; } else { vs.setAlertStatus("Requested doc"); populateTable(person); HospitalWorkRequest request = new HospitalWorkRequest(); request.setPerson(person); request.setMessage(message); request.setSender(userAccount); request.setStatus("alert sent"); // request.setRecordDate(timestamp); Organization org = null; for (Organization organization : enterprise.getOrganizationList().getOrganizationList()) { if (organization instanceof HospitalDoctorOrg) { org = organization; break; } } if (org != null) { userAccount.getWorkQueue().getWorkRequestList().add(request); org.getWorkQueue().getWorkRequestList().add(request); } populateDoctorAlertTable(); JOptionPane.showMessageDialog(null, "Alert Sent to doctor", "Infomation", JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Vital Sign is normal. Cannot forward to doctor", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e) { // JOptionPane.showMessageDialog(null, "","record",JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Please Select a Row", "WARNING", JOptionPane.WARNING_MESSAGE); } // for(WorkRequest req : userAccount.getWorkQueue().getWorkRequestList()){ // if(req instanceof HospitalWorkRequest){ // if(!((request.getMessage().equals(req.getMessage()))&& // (request.getRecordDate().equals(((HospitalWorkRequest)req).getRecordDate())))){ // } // else{ // JOptionPane.showMessageDialog(null, "Patient record is already sent to doctor", "WARNING", JOptionPane.WARNING_MESSAGE); // } // } // } }
From source file:gdt.jgui.tool.JEntityEditor.java
private Core[] getContent(boolean selected) { try {//w ww .jav a 2s . c o m JScrollPane scrollPane = (JScrollPane) tabbedPane.getSelectedComponent(); JTable table = (JTable) scrollPane.getViewport().getView(); DefaultTableModel model = (DefaultTableModel) table.getModel(); ListSelectionModel listModel = table.getSelectionModel(); int cnt = model.getRowCount(); if (cnt < 1) return null; ArrayList<Core> cl = new ArrayList<Core>(); for (int i = 0; i < cnt; i++) { if (selected) if (!listModel.isSelectedIndex(i)) continue; cl.add(new Core((String) model.getValueAt(i, 0), (String) model.getValueAt(i, 1), (String) model.getValueAt(i, 2))); } return cl.toArray(new Core[0]); } catch (Exception e) { LOGGER.severe(e.toString()); } return null; }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowserAdvancedFilter.java
private List<ContentSearchElement> getContentSearch() { List<ContentSearchElement> contentSearch = new ArrayList<ContentSearchElement>(); Map<ContentType, List<String>> contentSearchMap = new HashMap<ContentType, List<String>>(); DefaultTableModel model = ((DefaultTableModel) contentSearchTable.getModel()); int rowCount = model.getRowCount(); for (int i = 0; i < rowCount; i++) { ContentType contentType = (ContentType) model.getValueAt(i, 0); String searchText = (String) model.getValueAt(i, 1); if (searchText.length() > 0) { List<String> searchList = contentSearchMap.get(contentType); if (searchList == null) { searchList = new ArrayList<String>(); contentSearchMap.put(contentType, searchList); }/*from ww w.j a v a 2 s.c om*/ searchList.add(searchText); } } for (ContentType contentType : ContentType.getDisplayValues()) { if (contentSearchMap.containsKey(contentType)) { contentSearch.add(new ContentSearchElement(contentType.getContentTypeCode(), contentSearchMap.get(contentType))); } } return contentSearch; }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowserAdvancedFilter.java
private List<MetaDataSearchElement> getMetaDataSearch() throws MetaDataColumnException { List<MetaDataSearchElement> metaDataSearch = new ArrayList<MetaDataSearchElement>(); DefaultTableModel model = ((DefaultTableModel) metaDataSearchTable.getModel()); int rowCount = model.getRowCount(); if (rowCount == 0) { return null; } else {// w ww . j a v a 2 s.c o m for (int i = 0; i < rowCount; i++) { String metaDataName = (String) model.getValueAt(i, 0); String operator = ((MetaDataSearchOperator) model.getValueAt(i, 1)).toFullString(); String searchText = (String) model.getValueAt(i, 2); Boolean ignoreCase = (Boolean) model.getValueAt(i, 3); if (StringUtils.isNotEmpty(searchText)) { MetaDataColumn column = cachedMetaDataColumns.get(metaDataName); metaDataSearch.add(new MetaDataSearchElement(metaDataName, operator, column.getType().castValue(searchText), ignoreCase)); } } return metaDataSearch; } }
From source file:la2launcher.MainFrame.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); for (int i = 0; i < dtm.getRowCount(); i++) { for (int j = 0; j < procs.size(); j++) { if (Boolean.TRUE.equals(dtm.getValueAt(i, 1))) { if ((procs.get(j).hashCode() + "").equals(dtm.getValueAt(i, 0).toString())) { procs.get(j).destroyForcibly(); }//from w w w . j a v a 2 s . c o m } } } }
From source file:HW3.java
private void piechartValues(int[] val) { DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); int rowCount = model.getRowCount(); String temp;/*from w w w . jav a 2 s . c om*/ for (int i = 0; i < rowCount; i++) { temp = (String) model.getValueAt(i, 1); switch (temp) { case "1": val[0] += 1; break; case "2": val[1] += 1; break; case "3": val[2] += 2; break; case "4": val[3] += 1; break; case "5": val[4] += 1; break; } } }
From source file:la2launcher.MainFrame.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); int srow = jTable1.getSelectedRow(); if (srow < 0) { return;/* w w w . j a v a2 s.c o m*/ } Integer procid = (Integer) dtm.getValueAt(srow, 0); for (Process proc : procs) { if ((proc.hashCode() + "").equals(procid.toString())) { try { Field field = proc.getClass().getDeclaredField("handle"); if (!field.isAccessible()) { field.setAccessible(true); } long pid = field.getLong(proc); Kernel32 kernel = Kernel32.INSTANCE; W32API.HANDLE handle = new W32API.HANDLE(); handle.setPointer(Pointer.createConstant(pid)); long pid_ = kernel.GetProcessId(handle); User32 u32 = User32.INSTANCE; u32.EnumWindows(new WinUser.WNDENUMPROC() { @Override public boolean callback(WinDef.HWND hwnd, Pointer pntr) { char[] windowText = new char[512]; u32.GetWindowText(hwnd, windowText, 512); String wText = Native.toString(windowText); if (wText.isEmpty()) { return true; } if (wText.equals("Lineage II")) { //TODO: 111 IntByReference pid__ = new IntByReference(); u32.GetWindowThreadProcessId(hwnd, pid__); if ((pid__.getValue() + "").equals(pid_ + "")) { u32.SetForegroundWindow(hwnd); lastHWND = hwnd; } } return true; } }, null); } catch (NoSuchFieldException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (SecurityException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalArgumentException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:org.agmip.ui.afsirs.frames.SWFrame.java
private void jRadioKeyboardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioKeyboardActionPerformed // TODO add your handling code here: if (isPreviousSelectionSavedLocation) { DefaultTableModel model = (DefaultTableModel) soilTable.getModel(); if (prevSoil != null) { for (int i = 0; i < model.getRowCount(); i++) { prevSoil.getDU()[i] = (Double) model.getValueAt(i, 1); prevSoil.getWC()[i] = (Double) model.getValueAt(i, 2); }/*from w ww.j a va 2 s . c o m*/ } prevSoil = null; isPreviousSelectionSavedLocation = false; } toogleStateOfControls(evt); }
From source file:ca.uviccscu.lp.server.main.MainFrame.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed l.info("Remove game action activated"); //JOptionPane conf = new JOptionPane(); if (jTable1.getSelectedRow() >= 0) { int result = JOptionPane.showConfirmDialog(rootPane, "Are you sure you want to delete?", "Confirmation", 2, 3);// w w w . ja v a 2 s. c om //JDialog dialog = conf.createDialog(jPanel1, "Are you sure u want to delete?"); //dialog.show(); //Object selectedValue = conf.getValue(); l.trace("Game delete dialog code: " + result); if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { l.trace("Game delete cancelled"); } else if (result == JOptionPane.OK_OPTION) { DefaultTableModel mdl = (DefaultTableModel) jTable1.getModel(); String name = (String) mdl.getValueAt(jTable1.getSelectedRow(), 0); if (name != null) { l.trace("Removing game: " + name); GamelistStorage.removeGame(name); SettingsManager.getStorage().removeGame(name); mdl.removeRow(jTable1.getSelectedRow()); l.debug("Game removed: " + name); } else { mdl.removeRow(jTable1.getSelectedRow()); l.trace("Empty row - just erasing in table"); } } } MainFrame.updateGameInterfaceFromStorage(); }