List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:NewApplication.java
private void EditTable(Class clazz, Object object) { // TODO add your handling code here: DefaultTableModel model = (DefaultTableModel) jTable2.getModel(); model.setColumnCount(3);// w w w .j a v a 2 s. c om model.setNumRows(0); jTable2.setModel(model); TableColumn tc = jTable2.getColumnModel().getColumn(0); tc.setHeaderValue("Field Name"); tc = jTable2.getColumnModel().getColumn(1); tc.setHeaderValue("Value"); tc = jTable2.getColumnModel().getColumn(2); tc.setHeaderValue("Type"); try { Field[] fields = clazz.getDeclaredFields(); for (Field f : fields) { Object[] obs = new Object[3]; model = (DefaultTableModel) jTable2.getModel(); f.setAccessible(true); obs[0] = f.getName(); obs[1] = f.get(object); obs[2] = f.getType().getName(); if (f.getName() == "" || f.getName() == null) continue; model.addRow(obs); jTable2.setModel(model); } jTable2.repaint(); } catch (Exception ex) { } ; }
From source file:Interface.FoodCollectionSupervisor.FoodCollectionWorkArea.java
private void populateAssignedRequestTable() { DefaultTableModel model = (DefaultTableModel) tblAssignedRequests.getModel(); model.setRowCount(0);//ww w . j av a 2s.co m for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) { //request = (FoodCollectionWorkRequest) request; if (request.getStatus().equalsIgnoreCase("Pending for pickup")) { Object[] row = new Object[7]; row[0] = ((FoodCollectionWorkRequest) request); row[1] = ((FoodCollectionWorkRequest) request).getFood().getFoodType(); row[2] = ((FoodCollectionWorkRequest) request).getSender().getEmployee().getName(); row[3] = ((FoodCollectionWorkRequest) request).getFood().getFoodPriority(); row[4] = ((FoodCollectionWorkRequest) request).getSender().getEmployee().getAddress(); row[5] = ((FoodCollectionWorkRequest) request).getDriverName(); row[6] = request.getStatus(); model.addRow(row); } } }
From source file:localnetworkdrive.HomePage.java
private void Refbut1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Refbut1ActionPerformed // To fetch latest data on Videos from tracker and populate the gui containers //Fetch tracker ip trackerip = constants.Constants.serverIp + ":3000"; uploadfile.setVisible(false);//ww w. j a v a 2s .c o m jScrollPane2.setVisible(true); filelist.setVisible(true); //Initialize tracker interface fetchfiles f = new fetchfiles(); //Create image icons for display ImageIcon mp = new ImageIcon(HomePage.class.getResource("mp4.png")); //Carry out the fetch operation try { jsonresp = f.getHTML("http://" + trackerip + "/files/get/"); if (jsonresp.equals("")) { JOptionPane.showMessageDialog(null, "Oops. Looks like the Server and I aren't connected."); return; } //Convert data into a convenient file 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(); }; }; //Add initial columns model.addColumn("Icon"); model.addColumn("FileName"); model.addColumn("Remote Location"); //Check if data isnt empty if (json.length() > 0) downloadbut1.setEnabled(true); //Iterate through the data fetched and populate the table display for (int i = 0; i < json.length(); i++) { String switcher = new pathtranslator().decode(json.getJSONObject(i).getString("absolutepath")); switch (switcher.split("[.]")[switcher.split("[.]").length - 1]) { case "mp4": model.addRow(new Object[] { mp, switcher, json.getJSONObject(i).getString("ip") }); break; } } //Set the table display with updated data filelist1.setModel(model); } catch (HeadlessException | JSONException e) { JOptionPane.showMessageDialog(null, e.getMessage()); } }
From source file:Interface.FoodCollectionSupervisor.FoodCollectionWorkArea.java
private void populateCompletedRequestTable() { DefaultTableModel model = (DefaultTableModel) tblCompletedRequests.getModel(); model.setRowCount(0);//from w w w .ja v a 2s. c o m for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) { //request = (FoodCollectionWorkRequest) request; if (request.getStatus().equalsIgnoreCase("Food Delivered to Standard Authority")) { Object[] row = new Object[7]; row[0] = ((FoodCollectionWorkRequest) request); row[1] = ((FoodCollectionWorkRequest) request).getFood().getFoodType(); row[2] = ((FoodCollectionWorkRequest) request).getSender().getEmployee(); row[3] = ((FoodCollectionWorkRequest) request).getFood().getFoodPriority(); row[4] = ((FoodCollectionWorkRequest) request).getSender().getEmployee().getAddress(); row[5] = ((FoodCollectionWorkRequest) request).getDriverName(); row[6] = request.getStatus(); model.addRow(row); } } }
From source file:com.smanempat.controller.ControllerClassification.java
public void showClassificationResult(JTable tableResult, JTable tablePreview, String[] knnValue, int rowCountData, JLabel labelSiswaIPA, JLabel labelSiswaIPS, JLabel labelKeterangan, JYearChooser jYearChooser1, JYearChooser jYearChooser2, int kValue) { DefaultTableModel tableModelResult = new DefaultTableModel(); tableModelResult = (DefaultTableModel) tableResult.getModel(); int jumlahSiswaIPA = 0; int jumlahSiswaIPS = 0; for (int i = 0; i < rowCountData; i++) { if (knnValue[i].equals("IPA")) { jumlahSiswaIPA = jumlahSiswaIPA + 1; } else if (knnValue[i].equalsIgnoreCase("IPS")) { jumlahSiswaIPS = jumlahSiswaIPS + 1; }//from w w w . j av a 2s . co m String nis = tablePreview.getValueAt(i, 0).toString(); String nama = tablePreview.getValueAt(i, 1).toString(); String jenKel = tablePreview.getValueAt(i, 2).toString(); String nilaiUN = tablePreview.getValueAt(i, 3).toString(); String ptBindo = tablePreview.getValueAt(i, 4).toString(); String ptMtk = tablePreview.getValueAt(i, 5).toString(); String ptBing = tablePreview.getValueAt(i, 6).toString(); String ptIpa = tablePreview.getValueAt(i, 7).toString(); String minat = tablePreview.getValueAt(i, 8).toString(); String jurusan = knnValue[i]; Object[] resultData = { nis, nama, jenKel, nilaiUN, ptBindo, ptMtk, ptBing, ptIpa, minat, jurusan }; tableModelResult.addRow(resultData); } tableResult.setModel(tableModelResult); labelSiswaIPA.setText(jumlahSiswaIPA + ""); labelSiswaIPS.setText(jumlahSiswaIPS + ""); labelKeterangan.setText("Hasil Klasifikasi Penjurusan Siswa Pada Tahun Ajaran " + jYearChooser1.getYear() + "/" + jYearChooser2.getYear() + ", dengan paramater K = " + kValue + " adalah sebagai berikut "); }
From source file:localnetworkdrive.HomePage.java
private void RefbutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RefbutActionPerformed // To fetch latest data on Remote files from tracker and populate the gui containers //Fetch tracker ip trackerip = constants.Constants.serverIp + ":3000"; uploadfile.setVisible(false);// w ww. j a v a 2s .c om jScrollPane2.setVisible(true); filelist.setVisible(true); //Initialize tracker interface fetchfiles f = new fetchfiles(); //Create image icons for display ImageIcon jv = new ImageIcon(HomePage.class.getResource("java.png")); ImageIcon py = new ImageIcon(HomePage.class.getResource("python.png")); ImageIcon mp = new ImageIcon(HomePage.class.getResource("mp4.png")); ImageIcon def = new ImageIcon(HomePage.class.getResource("def.png")); ImageIcon pdf = new ImageIcon(HomePage.class.getResource("pdf.png")); //Carry out the fetch operation try { jsonresp = f.getHTML("http://" + trackerip + "/files/get/"); if (jsonresp.equals("")) { JOptionPane.showMessageDialog(null, "Oops. Looks like the Server and I aren't connected."); return; } //Convert data into a convenient file 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(); }; }; //Add initial columns model.addColumn("Icon"); model.addColumn("FileName"); model.addColumn("Remote Location"); //Check if data isnt empty if (json.length() > 0) downloadbut.setEnabled(true); //Iterate through the data fetched and populate the table display for (int i = 0; i < json.length(); i++) { String switcher = new pathtranslator().decode(json.getJSONObject(i).getString("absolutepath")); switch (switcher.split("[.]")[switcher.split("[.]").length - 1]) { case "py": model.addRow(new Object[] { py, switcher, json.getJSONObject(i).getString("ip") }); break; case "java": model.addRow(new Object[] { jv, switcher, json.getJSONObject(i).getString("ip") }); break; case "mp4": model.addRow(new Object[] { mp, switcher, json.getJSONObject(i).getString("ip") }); break; case "pdf": model.addRow(new Object[] { pdf, switcher, json.getJSONObject(i).getString("ip") }); break; default: model.addRow(new Object[] { def, switcher, json.getJSONObject(i).getString("ip") }); break; } } //Set the table display with updated data filelist.setModel(model); } catch (HeadlessException | JSONException e) { JOptionPane.showMessageDialog(null, e.getMessage()); } }
From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java
public void populateAlertFamilyTable() { DefaultTableModel model = (DefaultTableModel) vitalSignAlertsTable.getModel(); model.setRowCount(0);/*from w ww .j a v a 2 s. co m*/ for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) { if (request instanceof HosptoHouseWorkRequest) { Object[] row = new Object[5]; row[0] = request; String alert = ((HosptoHouseWorkRequest) request).getAdminMessage(); row[1] = alert == null ? "No Alert" : alert; row[2] = request.getRequestDate(); row[3] = ((HosptoHouseWorkRequest) request).getAppointmentDate(); //row[6] = ((HospitalWorkRequest)request).getAppointmentTime(); row[4] = request.getStatus(); model.addRow(row); } } }
From source file:HW3.java
private void displayBusinessTable(ResultSet result) throws SQLException { TableColumnModel tableModel = jTable2.getColumnModel(); tableModel.getColumn(0).setPreferredWidth(200); tableModel.getColumn(4).setPreferredWidth(200); DefaultTableModel model = (DefaultTableModel) jTable2.getModel(); while (result.next()) { String bid = result.getString(1); String bname = result.getString(2); String bcity = result.getString(5); String bstate = result.getString(4); String bstars = result.getFloat(3) + ""; String bzip = result.getString(6); model.addRow(new Object[] { bname, bcity, bstate, bstars, bid, bzip }); //System.out.println(bid + " " + bname + bcity + " " + bstate + " " + bstars); }/*from www .java 2 s.c o m*/ jTable2.repaint(); if (jTable2.getRowCount() == 0) { JOptionPane.showMessageDialog(topPanel, "NO DATA TO DISPLAY", "Message", JOptionPane.INFORMATION_MESSAGE); } }
From source file:Compare.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // TODO add your handling code here: DefaultTableModel model1 = (DefaultTableModel) FileDetails.getModel(); DefaultTableModel model2 = (DefaultTableModel) FileDetails1.getModel(); int count = 1; Boolean flag = false;//from w w w.ja v a 2s .c om for (Files filename : filenames1) { // String size = Long.toString(filename.Filesize) + "Bytes"; // model.addRow(new Object[]{count++,filename.Filename, size , filename.FileLocation}); boolean compare1 = false; for (Files fname : filenames2) { if (filename.Filename.equals(fname.Filename)) { File file1 = new File(filename.FileLocation); File file2 = new File(fname.FileLocation); flag = true; try { compare1 = FileUtils.contentEquals(file1, file2); } catch (IOException ex) { Logger.getLogger(Compare.class.getName()).log(Level.SEVERE, null, ex); } String size = Long.toString(filename.Filesize) + "Bytes"; String status; if (flag) { if (compare1) status = "same"; else status = " changed"; } else status = "deleted"; // model1.addColumn(count, new Object[] { status} ); model1.addRow(new Object[] { count++, filename.Filename, size, filename.FileLocation, status }); } } } }
From source file:gtu._work.ui.RenameUI.java
private void usePatternNewNameBtnActionPerformed() { try {//ww w . j a va 2 s .c om String findFileRegex = Validate.notBlank(findFileRegexText.getText(), "??Regex"); String renameRegex = Validate.notBlank(renameRegexText.getText(), "??"); Pattern renameRegexPattern = Pattern.compile("\\#(\\w+)\\#"); Matcher matcher2 = null; Pattern findFileRegexPattern = Pattern.compile(findFileRegex, Pattern.CASE_INSENSITIVE); Matcher matcher = null; DefaultTableModel model = JTableUtil.createModel(false, "??", "??", ""); int ind = 1; for (XFile f : fileList) { matcher = findFileRegexPattern.matcher(f.fileName); if (matcher.matches()) { StringBuffer sb = new StringBuffer(); matcher2 = renameRegexPattern.matcher(renameRegex); while (matcher2.find()) { String val = matcher2.group(1); if (val.matches("\\d+L")) { int index = Integer.parseInt(val.substring(0, val.length() - 1)); matcher2.appendReplacement(sb, DateFormatUtils .format(Long.parseLong(matcher.group(index)), "yyyyMMdd_HHmmss")); } else if (val.equalsIgnoreCase("date")) { matcher2.appendReplacement(sb, DateFormatUtils.format(f.file.lastModified(), "yyyyMMdd_HHmmss")); } else if (val.equalsIgnoreCase("serial")) { matcher2.appendReplacement(sb, String.valueOf(ind++)); } else if (StringUtils.isNumeric(val)) { int index = Integer.parseInt(val); matcher2.appendReplacement(sb, matcher.group(index)); } } matcher2.appendTail(sb); model.addRow(this.getXFile(f, sb.toString())); } } renameTable.setModel(model); } catch (Exception ex) { JCommonUtil.handleException(ex); } }