List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:userinterface.PatientRole.PatientWorkAreaJPanel.java
public void populateVStable() { DefaultTableModel model = (DefaultTableModel) tblVS.getModel(); model.setRowCount(0);//from w w w . jav a2 s. co m for (VitalSign vs : patient.getVitalSignHistory().getVitalSignHistory()) { Object[] row = new Object[5]; row[0] = vs; row[1] = vs.getRespiratoryRate(); row[2] = vs.getHeartRate(); row[3] = vs.getWeight(); row[4] = vs.getSystolicBloodPressure(); model.addRow(row); } }
From source file:userInterface.HospitalDoctor.HospitalDoctorWorkAreaJPanel.java
public void populateAlertsTable() { DefaultTableModel dtm = (DefaultTableModel) alertDetailsTable.getModel(); dtm.setRowCount(0);/* w w w .jav a 2 s. c om*/ for (WorkRequest request : hdOrg.getWorkQueue().getWorkRequestList()) { if (hdOrg.getWorkQueue().getWorkRequestList() != null) { Object[] row = new Object[6]; row[0] = request.getMessage(); row[1] = request.getSeverity(); row[2] = ((HospitalWorkRequest) request).getAlert(); row[3] = request.getRequestDate(); row[4] = request.getStatus(); row[5] = request.getResponseDate(); // row[1] = request.getStatus(); dtm.addRow(row); } } }
From source file:GeMSE.GS.Analysis.Stats.OneSampleCovariancePanel.java
private void GridView(double[][] matrix) { DefaultTableModel spaceTabMod = new DefaultTableModel() { @Override/*from www . ja v a 2 s. co m*/ public boolean isCellEditable(int row, int column) { return false; } }; String[] columnTitle = new String[matrix[0].length + 1]; columnTitle[0] = ""; for (int col = 1; col < columnTitle.length; col++) columnTitle[col] = "Column " + String.valueOf(col); spaceTabMod.setColumnIdentifiers(columnTitle); int col = 0; for (int r = 0; r < matrix.length; r++) { String[] row = new String[matrix[0].length + 1]; row[0] = "Row " + Integer.toString(r); for (col = 0; col < matrix[0].length; col++) row[col + 1] = Double.toString(matrix[r][col]); spaceTabMod.addRow(row); } matrixDG.setModel(spaceTabMod); matrixDG.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); matrixDG.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); ResizeColumnWidth(matrixDG); }
From source file:edu.ucla.stat.SOCR.motionchart.MotionMouseListener.java
protected JPanel getSeriesPanel(final JDialog dialog, ChartMouseEvent event) { MotionDataSet dataset = (MotionDataSet) event.getChart().getXYPlot().getDataset(); MotionBubbleRenderer renderer = (MotionBubbleRenderer) event.getChart().getXYPlot().getRenderer(); MotionTableModel model = dataset.getTableModel(); DefaultTableModel tModel = new DefaultTableModel(); ArrayList<Integer> visibleSeries = renderer.getVisibleSeries(); ArrayList<String> rowIds = new ArrayList<String>(); int columnCount = model.getColumnCount(); int r = 0;//from w ww . j av a2 s . c om for (int c = 0; c < columnCount; c++) { tModel.addColumn(model.getColumnName(c)); } Iterator<Integer> itr = visibleSeries.iterator(); while (itr.hasNext()) { ArrayList<Integer> rows = model.getKeyMap().get(dataset.getSeriesKey(itr.next())); Iterator<Integer> rItr = rows.iterator(); while (rItr.hasNext()) { int row = rItr.next(); tModel.addRow(new Object[0]); rowIds.add(new String(row + ":")); for (int c = 0; c < columnCount; c++) { tModel.setValueAt(model.getValueAt(row, c), r, c); } r++; } } return getPanel(dialog, tModel, rowIds); }
From source file:stockit.Trader.java
private void searchClientBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchClientBtnActionPerformed // TODO add your handling code here: String selectedClient = listOfClients.getSelectedValue(); System.out.println(selectedClient); try {//from www . j av a2 s . c o m DBConnection dbcon = new DBConnection(); dbcon.establishConnection(); Statement stmt = dbcon.con.createStatement(); ResultSet rs = stmt.executeQuery( "SELECT stock.stockID, company.Name, stock_sector.Sector, stock_daily_performance.Currency, stock_daily_performance.High, stock_daily_performance.Low, stock_daily_performance.Closing_Price, has_positions.Qty, (stock_daily_performance.Opening_Price - stock_daily_performance.Closing_Price) AS Today_Change, ((stock_daily_performance.Opening_Price - stock_daily_performance.Closing_Price) * has_positions.Qty) AS Profit\n" + "FROM stock, stock_sector, stock_daily_performance, has_positions, account, company, client\n" + "WHERE client.Name = '" + selectedClient + "'" + "AND client.Client_SSN = account.Client_SSN AND account.Account_ID = has_positions.Account_ID AND stock_daily_performance.StockID = has_positions.Stock_ID AND stock.StockID = has_positions.Stock_ID AND stock_sector.StockID = has_positions.Stock_ID AND company.StockID = stock.StockID AND Date IN\n" + "( Select * from \n" + "(\n" + "SELECT max(Date) \n" + "FROM stock_daily_performance, stock\n" + "where stock_daily_performance.StockID=stock.StockID\n" + "group by stock.StockID\n" + "ORDER BY Date\n" + ") temp_table)"); DefaultTableModel model = (DefaultTableModel) table.getModel(); model.setRowCount(0); while (rs.next()) { System.out.println( rs.getString("stockID") + "\t" + rs.getString("Name") + "\t" + rs.getString("Sector") + "\t" + rs.getString("Currency") + "\t" + rs.getString("Closing_Price") + "\t" + rs.getString("Qty") + rs.getString("Today_Change")); model.addRow(new Object[] { rs.getString("stockID"), rs.getString("Name"), rs.getString("Sector"), rs.getString("Qty"), rs.getString("High"), rs.getString("Low"), rs.getString("Closing_Price"), rs.getString("Today_Change"), rs.getString("Currency"), rs.getString("Profit") }); } dbcon.con.close(); } catch (Exception ex) { Logger.getLogger(clientLogin.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:userinterface.PatientRole.PatientAppointmentsJPanel.java
public void populateAppointments() { DefaultTableModel model = (DefaultTableModel) appointMentRequestJTable1.getModel(); model.setRowCount(0);//from w w w . jav a 2 s .c om for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) { if (request instanceof AppointmentWorkRequest) { Object[] row = new Object[5]; row[0] = request; row[1] = request.getReceiver() == null ? null : request.getReceiver().getEmployee().getName(); row[2] = ((AppointmentWorkRequest) request).getAppointmentDateTime() == null ? null : ((AppointmentWorkRequest) request).getAppointmentDateTime(); row[3] = request.getStatus(); String result = ((AppointmentWorkRequest) request).getTestResult(); row[4] = result == null ? "Waiting" : result; model.addRow(row); } } }
From source file:UserInterface.CustomerRole.CustomerTaxJPanel.java
public void populateTable() { DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); dtm.setRowCount(0);//from ww w . j a v a2s . com for (Sensor sensor : userAccount.getCustomer().getSensorDirectory().getSensorDirectory()) { Object[] row = new Object[9]; row[0] = sensor; row[1] = sensor.getCurrentEmissionCO2(); row[2] = sensor.getNormalCO2(); row[3] = sensor.getCurrentEmissionNOx(); row[4] = sensor.getNormalNOx(); row[5] = sensor.getSolarCurrentEmissionCO2(); row[6] = sensor.getSolarNormalCO2(); row[7] = sensor.getSolarCurrentEmissionNOx(); row[8] = sensor.getSolarNormalNOx(); dtm.addRow(row); } }
From source file:UserInterface.SupplierRole.ProductSalesReviewJPanel.java
private void populateSalesTable() { DefaultTableModel defaultTableModel = (DefaultTableModel) salesTable.getModel(); defaultTableModel.setRowCount(0);//from ww w . j a v a 2 s . c om if (null != supplier.getProductCatalog()) { int totalSalesValue = 0; int productSalesValue = 0; for (Product product : supplier.getProductCatalog().getProductList()) { Object[] rows = new Object[4]; productSalesValue = product.getPrice() * (product.getInitialQuantity() - product.getAvailable()); rows[0] = product; rows[1] = product.getInitialQuantity() - product.getAvailable(); rows[2] = product.getPrice(); rows[3] = productSalesValue; totalSalesValue = totalSalesValue + productSalesValue; defaultTableModel.addRow(rows); } totalSaleTextField.setText(String.valueOf(totalSalesValue)); } }
From source file:gdt.jgui.tool.JEntityEditor.java
private void replaceTable(Core[] ca) { try {/*from w w w .j a va2 s . c o m*/ JScrollPane scrollPane = (JScrollPane) tabbedPane.getSelectedComponent(); JTable table = (JTable) scrollPane.getViewport().getView(); DefaultTableModel model = (DefaultTableModel) table.getModel(); while (model.getRowCount() > 0) model.removeRow(0); int cnt = ca.length; if (cnt < 1) return; for (int i = 0; i < cnt; i++) model.addRow(new String[] { ca[i].type, ca[i].name, ca[i].value }); } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:king.flow.action.DefaultMsgSendAction.java
private void showOnComponent(Object metaNode, TLSResult result) { Component meta = (Component) metaNode; getLogger(CommunicationWorker.class.getName()).log(Level.INFO, "Display component[{0}] type : {1}", new Object[] { String.valueOf(meta.getId()), meta.getType().value() }); JsonParser jsonParser;//from w w w . j av a 2 s . c o m JsonArray arrays; switch (meta.getType()) { case TABLE: try { jsonParser = new JsonParser(); arrays = jsonParser.parse(result.getOkMsg()).asArray(); JTable table = getBlock(meta.getId(), JTable.class); DefaultTableModel model = (DefaultTableModel) table.getModel(); model.setRowCount(0); for (Iterator it = arrays.iterator(); it.hasNext();) { JsonArray row = (JsonArray) it.next(); Vector<String> rowData = new Vector<>(); for (Object v : row) { rowData.add(v.toString()); } model.addRow(rowData); } } catch (Exception e) { getLogger(CommunicationWorker.class.getName()).log(Level.WARNING, "Invalid array data [ {0} ] for TABLE component[{1}], \n exception is {2}", new Object[] { result.getOkMsg(), String.valueOf(meta.getId()), e }); } break; case ADVANCED_TABLE: try { jsonParser = new JsonParser(); JsonObject jsonObj = jsonParser.parse(result.getOkMsg()).asObject(); Integer total = jsonObj.getInt(ADVANCED_TABLE_TOTAL_PAGES); Integer page = jsonObj.getInt(ADVANCED_TABLE_CURRENT_PAGE); arrays = jsonObj.getArray(ADVANCED_TABLE_VALUE); getLogger(CommunicationWorker.class.getName()).log(Level.INFO, "Dump JSON DATA for ADVANCED_TABLE: \n{0} \ntotal: {1} \npage: {2}", new Object[] { jsonObj.toString(), total, page }); JXMsgPanel advanceTable = getBlock(meta.getId(), JXMsgPanel.class); advanceTable.refreshTotalPages(total); advanceTable.refreshCurrentPage(page); advanceTable.refreshTable(arrays); } catch (Exception e) { getLogger(CommunicationWorker.class.getName()).log(Level.WARNING, "Invalid complex data [ {0} ] for ADVANCED_TABLE component[{1}] \n exception is {2}", new Object[] { result.getOkMsg(), String.valueOf(meta.getId()), e }); } break; case LABEL: JLabel label = getBlock(meta.getId(), JLabel.class); if (result.getRetCode() == 0) { label.setText(StringEscapeUtils.unescapeHtml(result.getOkMsg())); } else { label.setText(StringEscapeUtils.unescapeHtml(result.getErrMsg())); } break; case TEXT_FIELD: JTextField textField = getBlock(meta.getId(), JTextField.class); if (result.getRetCode() == 0) { textField.setText(result.getOkMsg()); } else { CommonUtil.showErrorMsg(textField.getTopLevelAncestor(), result.getErrMsg()); } break; default: getLogger(CommunicationWorker.class.getName()).log(Level.WARNING, "Unsupported displayed component type : {0}", meta.getType()); } }