List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:UserInterface.AuthorityWorkArea.DrugAnalysisJPanel.java
private void populateMedicineApprovalTable() { DefaultTableModel model = (DefaultTableModel) medicineAreajTable.getModel(); model.setRowCount(0);/*from w ww.ja v a 2 s. c o m*/ Authority authority = ecosystem.getAuthority(); for (WorkRequest wr : authority.getWorkQueue().getWorkRequestList()) { DrugApprovalRequest dar = (DrugApprovalRequest) wr; if (dar instanceof WorkRequest) { for (Drug drug : dar.getDrugDirectory().getDrugList()) { Object[] row = new Object[10]; row[0] = dar.getReqId(); row[1] = drug.getDrugName(); row[2] = drug; row[3] = drug.getDisease().getDiseaseName(); row[4] = dar.getSender() == null ? ("N/A") : dar.getSender().getPerson().getName(); row[5] = dar.getReceiver() == null ? ("N/A") : dar.getReceiver().getPerson().getName(); row[6] = dar; row[7] = dar.getMessage() == null ? ("Evaluation Required") : wr.getMessage(); row[8] = dar.getCompanyName(); row[9] = dar.getCompanyId(); model.addRow(row); } } } }
From source file:com.firmansyah.imam.sewa.kendaraan.FormUser.java
public void showDataUser() { try {/*from www . ja va 2s.c o m*/ getDataURL dataurl = new getDataURL(); DefaultTableModel model = (DefaultTableModel) tblPelanggan.getModel(); model.setRowCount(0); String url = Path.serverURL + "/user/show/"; String data = dataurl.getData(url); Object obj = JSONValue.parse(data); JSONArray dataArray = (JSONArray) obj; System.out.println("Banyak datanya : " + dataArray.size()); for (int i = 0; i < dataArray.size(); i++) { JSONObject getData = (JSONObject) dataArray.get(i); String cek_status = getData.get("status").toString(); if (cek_status.equals("0")) { cek_status = "Non Aktif"; } else { cek_status = "Aktif"; } Object[] row = { i + 1, getData.get("nama"), getData.get("username"), cek_status, getData.get("id"), }; model.addRow(row); } } catch (IOException ex) { Logger.getLogger(FormUser.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:userinterface.PatientRole.PatientWorkAreaJPanel.java
public void populateAppointments() { DefaultTableModel model = (DefaultTableModel) appointMentRequestJTable1.getModel(); int index = 1; model.setRowCount(0);//from www .ja v a 2 s . co m for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) { if (request instanceof AppointmentWorkRequest) { Object[] row = new Object[4]; //row[0] = request.getMessage(); row[0] = index++; 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:ui.Analyze.java
private void generateLaba(LocalDate ld1, LocalDate ld2) throws SQLException { org.jfree.data.category.DefaultCategoryDataset data = new org.jfree.data.category.DefaultCategoryDataset(); javax.swing.table.DefaultTableModel m = (javax.swing.table.DefaultTableModel) ketTbl.getModel(); ketTbl.removeAll();//from www .j a va 2s . c o m LocalDate awal, akhir, loop; boolean min; if (ld2.isBefore(ld1)) { awal = ld2; akhir = ld1; min = false; } else { akhir = ld2; awal = ld1; min = true; } for (loop = awal; min ? !loop.isAfter(akhir) : !loop.isBefore(akhir);) { Number u = getUntung(loop), r = getRugi(loop); data.addValue(u.longValue() - r.longValue(), "Laba", loop); m.addRow(new Object[] { loop, u.longValue() - r.longValue() }); if (min) loop = loop.plusDays(1); else loop = loop.minusDays(1); } org.jfree.chart.ChartPanel cp = new org.jfree.chart.ChartPanel(ChartFactory.createLineChart("Laba", "Tanggal", "Laba", data, PlotOrientation.VERTICAL, true, true, false)); cp.setSize(pnlLaba.getSize()); if (0 < pnlLaba.getComponentCount()) pnlLaba.removeAll(); pnlLaba.add(cp); }
From source file:la2launcher.MainFrame.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed int c = Integer.valueOf(jTextField1.getText()); if (c > procLimit) { JOptionPane.showMessageDialog(null, " ?? ?."); return;// ww w.jav a 2 s .co m } gamePath = jTextField2.getText(); new Thread(new Runnable() { @Override public void run() { if (!new File(gamePath + "\\system\\l2.exe").exists()) { JOptionPane.showMessageDialog(MainFrame.this, "? l2.exe ? . ?/ ."); return; } jButton1.setEnabled(false); for (int i = 0; i < c; i++) { try { Process proc = Runtime.getRuntime().exec(gamePath + "\\system\\l2.exe"); procs.add(proc); DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); dtm.addRow(new Object[] { proc.hashCode(), Boolean.TRUE }); if (i + 1 < c) { try { Thread.sleep(launchDelay); } catch (Exception ex) { logg(""); logg(ex); } } } catch (Exception ex) { logg(""); logg(ex); } } jButton1.setEnabled(true); } }).start(); }
From source file:localnetworkdrive.HomePage.java
private void Refbut2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Refbut2ActionPerformed // To fetch latest data on Screen Mirroring from tracker and populate the gui containers trackerip = constants.Constants.serverIp + ":3000"; //Initialize tracker interface fetchfiles f = new fetchfiles(); //Fetch latest data available for stream from tracker try {//w w w . ja v a 2 s . c o m jsonresp = f.getHTML("http://" + trackerip + "/device/get"); if (jsonresp.equals("")) { JOptionPane.showMessageDialog(null, "Oops. Looks like the Server and I aren't connected."); return; } else startstream.setEnabled(true); //Convert data into a convenient format json = new JSONArray(jsonresp); //Create a data model for the table display DefaultTableModel model = new DefaultTableModel() { @Override public Class getColumnClass(int column) { return getValueAt(0, column).getClass(); }; }; //Populate initial columns on table display model.addColumn("IP Address"); model.addColumn("Computer ID"); //Check if data isnt empty if (json.length() > 0) downloadbut1.setEnabled(true); //Iterate through data to populate the table display for (int i = 0; i < json.length(); i++) { model.addRow(new Object[] { json.getJSONObject(i).getString("ip"), json.getJSONObject(i).getString("hash") }); } mirrorlist.setModel(model); } catch (HeadlessException | JSONException e) { JOptionPane.showMessageDialog(null, e.getMessage()); } }
From source file:com.smanempat.controller.ControllerEvaluation.java
private double[][] evaluationModel(JTable tableResult, JTable tableConfMatrix, JLabel totalAccuracy, JTable tableTahunTesting, JTable tableDataSetTesting, String[] knnValue, int nilaiK, JPanel panelChart) throws SQLException { int actIPA = 0; int actIPS = 0; int trueIPA = 0; int falseIPA = 0; int trueIPS = 0; int falseIPS = 0; int classIPA = 0; int classIPS = 0; double recIPA; double recIPS; double preIPA; double preIPS; double accuracy; DefaultTableModel tableModelConf = (DefaultTableModel) tableConfMatrix.getModel(); DefaultTableModel tableModelRes = (DefaultTableModel) tableResult.getModel(); String[] tempJurusan = getJurusanTest(tableTahunTesting, tableDataSetTesting); if (tableModelRes.getRowCount() != 0) { tableModelRes.setRowCount(0);// ww w. ja va2s . c o m } for (int j = 0; j < tableDataSetTesting.getRowCount(); j++) { String nis = tableDataSetTesting.getValueAt(j, 0).toString(); String jurusan = tempJurusan[j]; String classified = knnValue[j]; Object[] tableContent = { nis, jurusan, classified }; tableModelRes.addRow(tableContent); tableResult.setModel(tableModelRes); } /*Hitung Jumlah Data Actual IPA dan IPS*/ for (int j = 0; j < tempJurusan.length; j++) { if (tempJurusan[j].equals("IPA")) { actIPA = actIPA + 1; } else if (tempJurusan[j].equals("IPS")) { actIPS = actIPS + 1; } } /*Hitung Jumlah Data Classified IPA dan IPS*/ for (int j = 0; j < knnValue.length; j++) { if (tableResult.getValueAt(j, 1).equals("IPA")) { if (tableResult.getValueAt(j, 1).equals(tableResult.getValueAt(j, 2))) { trueIPA = trueIPA + 1; } else { falseIPS = falseIPS + 1; } } else if (tableResult.getValueAt(j, 1).equals("IPS")) { if (tableResult.getValueAt(j, 1).equals(tableResult.getValueAt(j, 2))) { trueIPS = trueIPS + 1; } else { falseIPA = falseIPA + 1; } } } // System.out.println("trueIPA =" + trueIPA); // System.out.println("falseIPA =" + falseIPA); // System.out.println("falseIPS =" + falseIPS); // System.out.println("trueIPS =" + trueIPS); /*Hitung Nilai Recall, Precision, dan Accuracy*/ preIPA = (double) trueIPA / (trueIPA + falseIPA); preIPS = (double) trueIPS / (trueIPS + falseIPS); recIPA = (double) trueIPA / (trueIPA + falseIPS); recIPS = (double) trueIPS / (trueIPS + falseIPA); accuracy = (double) (trueIPA + trueIPS) / (trueIPA + trueIPS + falseIPA + falseIPS); /*Tampung Nilai Recall, Precision, dan Accuracy*/ double[][] tempEval = new double[3][1]; tempEval[0][0] = accuracy; tempEval[1][0] = recIPA; tempEval[2][0] = preIPA; /*Set Nilai TF, TN, FP, FN ke Tabel Confusion Matrix*/ tableModelConf.setValueAt("Actual IPA", 0, 0); tableModelConf.setValueAt("Actual IPS", 1, 0); tableModelConf.setValueAt("Class Precision", 2, 0); tableModelConf.setValueAt(trueIPA, 0, 1); tableModelConf.setValueAt(falseIPS, 0, 2); tableModelConf.setValueAt(falseIPA, 1, 1); tableModelConf.setValueAt(trueIPS, 1, 2); /*Set Nilai Recall, Precision, dan Accuracy ke Tabel Confusion Matrix*/ if (Double.isNaN(preIPA)) { tableModelConf.setValueAt("NaN" + " %", 2, 1); } else { tableModelConf.setValueAt(df.format(preIPA * 100) + " %", 2, 1); } if (Double.isNaN(preIPS)) { tableModelConf.setValueAt("NaN" + " %", 2, 2); } else { tableModelConf.setValueAt(df.format(preIPS * 100) + " %", 2, 2); } if (Double.isNaN(recIPA)) { tableModelConf.setValueAt("NaN" + " %", 0, 3); } else { tableModelConf.setValueAt(df.format(recIPA * 100) + " %", 0, 3); } if (Double.isNaN(recIPS)) { tableModelConf.setValueAt("NaN" + " %", 1, 3); } else { tableModelConf.setValueAt(df.format(recIPS * 100) + " %", 1, 3); } if (Double.isNaN(accuracy)) { totalAccuracy.setText("Overall Accuracy is " + "NaN" + " %"); } else { totalAccuracy.setText("Overall Accuracy is " + df.format(accuracy * 100) + " %"); } // System.out.println("Recall IPA = " + recIPA); // System.out.println("Recall IPA =" + recIPS); // System.out.println("Precision IPA = " + preIPA); // System.out.println("Precision IPS = " + preIPS); // System.out.println("Overall Accuracy = " + accuracy); return tempEval; }
From source file:net.sf.maltcms.chromaui.msviewer.ui.panel.MassSpectrumPanel.java
public void addIdentification() { // Create a custom NotifyDescriptor, specify the panel instance as a parameter + other params NotifyDescriptor nd = new NotifyDescriptor(ddp, // instance of your panel "Select Databases and Settings", // title of the dialog NotifyDescriptor.OK_CANCEL_OPTION, // it is Yes/No dialog ... NotifyDescriptor.PLAIN_MESSAGE, // ... of a question type => a question mark icon null, // we have specified YES_NO_OPTION => can be null, options specified by L&F, // otherwise specify options as: // new Object[] { NotifyDescriptor.YES_OPTION, ... etc. }, NotifyDescriptor.OK_OPTION // default option is "Yes" );/*from ww w. j a va 2s . c o m*/ ddp.updateView(); // let's display the dialog now... if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) { if (ddp.getSelectedDatabases().isEmpty()) { return; } Runnable r = new Runnable() { @Override public void run() { IQuery<IScan> query = Lookup.getDefault().lookup(IQueryFactory.class).createQuery( ddp.getSelectedDatabases(), ddp.getRetentionIndexCalculator(), ddp.getSelectedMetabolitePredicate(), ddp.getMatchThreshold(), ddp.getMaxNumberOfHits(), ddp.getRIWindow(), seriesToScan.values().toArray(new IScan[seriesToScan.size()])); try { List<QueryResultList<IScan>> results = query.call(); Box outerBox = Box.createVerticalBox(); for (QueryResultList<IScan> mdqrl : results) { for (IQueryResult<IScan> result : mdqrl) { Box vbox = Box.createVerticalBox(); JLabel label = new JLabel("Results for scan " + result.getScan().getScanIndex() + " at " + result.getScan().getScanAcquisitionTime() + " with ri: " + result.getRetentionIndex()); JLabel dbLabel = new JLabel( "DB: " + result.getDatabaseDescriptor().getResourceLocation()); vbox.add(label); vbox.add(dbLabel); JLabel parameterLabel = new JLabel("Minimum Score: " + ddp.getMatchThreshold() + "; Maximum #Hits Returned: " + ddp.getMaxNumberOfHits()); vbox.add(parameterLabel); DefaultTableModel dlm = new DefaultTableModel( new String[] { "Score", "RI", "Name", "ID", "MW", "Formula", "Max Mass" }, 0); for (IMetabolite metabolite : result.getMetabolites()) { String name = metabolite.getName(); if (name.lastIndexOf("_") != -1) { name = name.substring(name.lastIndexOf("_") + 1); } dlm.addRow(new Object[] { result.getScoreFor(metabolite), result.getRiFor(metabolite), name, metabolite.getID(), metabolite.getMW(), metabolite.getFormula(), metabolite.getMaxMass() }); } JTable jl = new JTable(dlm); JScrollPane resultScrollPane = new JScrollPane(jl); jl.setAutoCreateRowSorter(true); jl.setUpdateSelectionOnSort(true); vbox.add(resultScrollPane); outerBox.add(vbox); outerBox.add(Box.createVerticalStrut(10)); } } JScrollPane jsp = new JScrollPane(outerBox); NotifyDescriptor nd = new NotifyDescriptor(jsp, // instance of your panel "Database Search Results", // title of the dialog NotifyDescriptor.OK_CANCEL_OPTION, // it is Yes/No dialog ... NotifyDescriptor.PLAIN_MESSAGE, // ... of a question type => a question mark icon null, // we have specified YES_NO_OPTION => can be null, options specified by L&F, // otherwise specify options as: // new Object[] { NotifyDescriptor.YES_OPTION, ... etc. }, NotifyDescriptor.OK_OPTION // default option is "Yes" ); if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) { } //DBConnectionManager.close(); } catch (Exception ex) { Exceptions.printStackTrace(ex); } } }; RequestProcessor.getDefault().post(r); } }
From source file:com.mirth.connect.client.ui.panels.connectors.PollingSettingsPanel.java
private void clearProperties() { scheduleTypeComboBox.setSelectedItem(PollingType.INTERVAL.getDisplayName()); noStartPollRadioButton.setSelected(true); SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm aa"); pollingTimePicker.setDate(dateFormat.format(Calendar.getInstance().getTime())); DefaultTableModel model = (DefaultTableModel) cronJobsTable.getModel(); for (int index = model.getRowCount() - 1; index >= 0; index--) { model.removeRow(index);/*from w w w . j a v a 2s . com*/ } Vector<String> row = new Vector<String>(); if (channelContext) { pollingFrequencyTypeComboBox.setSelectedItem(POLLING_FREQUENCY_SECONDS); pollingFrequencyField.setText("5"); row.add(defaultCronJob); row.add("Run every 5 seconds."); } else { pollingFrequencyTypeComboBox.setSelectedItem(POLLING_FREQUENCY_HOURS); pollingFrequencyField.setText("1"); row.add("0 0 */1 * * ?"); row.add("Run hourly."); } model.addRow(row); cachedAdvancedConnectorProperties = new PollConnectorPropertiesAdvanced(); }
From source file:edu.ku.brc.specify.plugins.sgr.SGRResultsDisplay.java
public SGRResultsDisplay(int width, MatchResults results) { if (Main.m_settings == null) { Main.m_settings = new JSettings(true); Main.m_settings.load(/* w ww.j a v a 2 s . com*/ JPathHelper.addSeparator(System.getProperty("user.home")) + JSettings.SETTINGS_FILE, "1.8"); Main.m_sysLocale = Locale.getDefault(); if (Main.m_settings.getLocale().length() > 0) { Locale.setDefault(new Locale(Main.m_settings.getLocale())); } } SGRColumnOrdering columns = SGRColumnOrdering.getInstance(); String[] fields = columns.getFields(); DefaultTableModel resultsTableModel = new DefaultTableModel(columns.getHeadings(), 0); final List<List<Color>> rowColors = new LinkedList<List<Color>>(); for (Match result : results) { SGRRecord match = result.match; float score = result.score; float maxScore = 22.0f; //results.maxScore; List<Color> cellColors = new LinkedList<Color>(); List<String> data = new LinkedList<String>(); for (String field : fields) { if (field.equals("id")) { data.add(match.id); cellColors.add(SGRColors.colorForScore(score, maxScore)); } else if (field.equals("score")) { data.add(((Float) score).toString()); cellColors.add(SGRColors.colorForScore(score, maxScore)); } else { data.add(StringUtils.join(match.getFieldValues(field).toArray(), ';')); Float fieldContribution = result.fieldScoreContributions().get(field); Color color = SGRColors.colorForScore(score, maxScore, fieldContribution); cellColors.add(color); } } resultsTableModel.addRow(data.toArray()); rowColors.add(cellColors); } JTable table = createTable(resultsTableModel, rowColors); Dimension preferredSize = table.getPreferredSize(); preferredSize.width = Math.min((int) (0.9 * width), preferredSize.width); table.setPreferredScrollableViewportSize(preferredSize); table.getColumnModel().addColumnModelListener(this); add(new JScrollPane(table)); }