List of usage examples for javax.swing.table DefaultTableModel setRowCount
public void setRowCount(int rowCount)
From source file:userinterface.DoctorWorkArea.DiagnosePatientJPanel.java
public void populateLabRequestTable() { DefaultTableModel model = (DefaultTableModel) labTestRequestJTable.getModel(); model.setRowCount(0); for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) { if (request instanceof LabTechnicianWorkRequest) { Object[] row = new Object[5]; row[0] = request;/*from w w w. ja va 2 s . c o m*/ row[1] = request.getMessage(); row[2] = request.getReceiver(); row[3] = request.getStatus(); String result = ((LabTechnicianWorkRequest) request).getTestResult(); row[4] = result == null ? "Waiting" : result; model.addRow(row); } } }
From source file:edu.ucla.stat.SOCR.chart.demo.SOCR_EM_MixtureModelChartDemo.java
protected void resetRTableRows(int n) { for (int s = 0; s < num_series; s++) { DefaultTableModel tModel_results = (javax.swing.table.DefaultTableModel) resultsTables[s].getModel(); tModel_results.setRowCount(n); resultsTables[s].setModel(tModel_results); }/*from w w w.j av a2s . c om*/ }
From source file:la2launcher.MainFrame.java
private void processValidation(boolean full) { final long initTime = new Date().getTime(); final String patcherUrl = "http://" + updateHost + "/hf/updater.lst.la2";//new ArrayBlockingQueue<Runnable>(10000) final ThreadPoolExecutor tpe = new ThreadPoolExecutor(5, 5, 1, TimeUnit.HOURS, new ArrayBlockingQueue<Runnable>(10000)); tpe.execute(new Runnable() { @Override/* ww w . j a v a 2 s .c om*/ public void run() { jTextArea2.setText(""); try { if (full) { jTextArea2.setText(jTextArea2.getText() + "\r\n? "); } else { jTextArea2.setText(jTextArea2.getText() + "\r\n? system"); } File patcher = File.createTempFile("la2", "la2"); patcher.deleteOnExit(); File patcherExt = File.createTempFile("la2", "la2"); patcherExt.deleteOnExit(); FileOutputStream fos = new FileOutputStream(patcher); CloseableHttpClient httpclient = HttpClients.createDefault(); HttpGet httpGet = new HttpGet(patcherUrl); CloseableHttpResponse response1 = httpclient.execute(httpGet); HttpEntity entity1 = response1.getEntity(); copyStream(entity1.getContent(), fos, null); response1.close(); fos.close(); jTextArea2.setText(jTextArea2.getText() + "\r\n?? ? ?: " + patcherUrl); fixBzip2File(patcher); jTextArea2.setText(jTextArea2.getText() + "\r\n ?"); BZip2CompressorInputStream bz = new BZip2CompressorInputStream(new FileInputStream(patcher)); OutputStream pout = new FileOutputStream(patcherExt); copyStream(bz, pout, new CopyListener() { @Override public void transfered(int n) { bytesRecieved += n; bytesRecievedTotal += n; } }); pout.close(); bz.close(); jTextArea2.setText(jTextArea2.getText() + "\r\n? ?"); if (full) { jTextArea2.setText(jTextArea2.getText() + "\r\n "); } else { jTextArea2.setText(jTextArea2.getText() + "\r\n system"); } DefaultTableModel model = (DefaultTableModel) jTable2.getModel(); model.setRowCount(0); int filesCount = scanSumFilesCount(patcherExt, full); jProgressBar1.setMinimum(0); jProgressBar1.setMaximum(filesCount); jProgressBar1.setValue(0); jLabel4.setText("0/" + filesCount); scanSumFile(patcherExt, new SumHandler() { private ReentrantLock lock = new ReentrantLock(); @Override public void handle(MDNamePair pair) { try { jProgressBar1.setIndeterminate(false); //lock.unlock(); tpe.execute(new Runnable() { @Override public void run() { try { lock.lock(); //printMsg(pair.filename); String crc = digest(new File(gamePath + pair.filename)); //printMsg(" : " + pair.crc); //printMsg(" ? ? : " + crc); if (!pair.crc.equals(crc)) { DefaultTableModel dtm = (DefaultTableModel) jTable2.getModel(); dtm.addRow(new Object[] { pair.filename, false }); } jProgressBar1.setValue(jProgressBar1.getValue() + 1); jLabel4.setText(jProgressBar1.getValue() + "/" + filesCount); lock.unlock(); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } finally { //if (lock.isLocked()) lock.unlock(); } } }); } finally { //if (lock.isLocked()) lock.unlock(); } } }, full); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } }); jButton5.setEnabled(false); jButton6.setEnabled(false); jButton7.setEnabled(false); jButton8.setEnabled(false); jButton10.setEnabled(false); jProgressBar1.setIndeterminate(true); new Thread() { @Override public void run() { do { long millis = new Date().getTime(); try { sleep(300); } catch (InterruptedException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } millis = new Date().getTime() - millis; BigDecimal totBig = new BigDecimal(bytesRecievedTotal / (1024 * 1024.0)); totBig = totBig.setScale(2, BigDecimal.ROUND_CEILING); jLabel5.setText("?: " + (bytesRecieved / millis) + "KB/s. : " + totBig + " MB"); bytesRecieved = 0; } while (tpe.getActiveCount() > 0); tpe.shutdown(); jButton5.setEnabled(true); jButton6.setEnabled(true); jButton7.setEnabled(true); jButton8.setEnabled(true); jButton10.setEnabled(true); jProgressBar1.setIndeterminate(false); printMsg(" " + (new Date().getTime() - initTime) + " ?."); } }.start(); }
From source file:hw.java
private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked MongoCollection<Document> rcoll = db.getCollection("review"); String user = jTable2.getValueAt(jTable2.getSelectedRow(), 3).toString(); BasicDBObject userid = new BasicDBObject("user_id", user); FindIterable<Document> cursor2; jTextField8.setText("db.review.find(" + userid.toString() + ")"); cursor2 = rcoll.find(userid);//from ww w. j ava 2 s. c om // ResultSet rs = stmt.executeQuery(qry); String Columnames[] = { "user_id", "business_id", "text" }; DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel(); dtm.setColumnCount(0); dtm.setRowCount(0); int numberOfColumns = Columnames.length; for (int i = 0; i < numberOfColumns; i++) { String name = Columnames[i]; dtm.addColumn(name); } cursor2.forEach(new Block<Document>() { @Override public void apply(final Document document) { Object rowData[] = new Object[numberOfColumns]; rowData[0] = document.get("user_id"); rowData[1] = document.get("business_id"); rowData[2] = document.get("text"); dtm.addRow(rowData); rowData = null; } }); }
From source file:hw.java
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked //try {// w w w.j a v a2s.co m MongoCollection<Document> rcoll = db.getCollection("review"); String business = jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString(); BasicDBObject businessid = new BasicDBObject("business_id", business); FindIterable<Document> cursor2; jTextField8.setText("db.review.find(" + businessid.toString() + ")"); cursor2 = rcoll.find(businessid); // ResultSet rs = stmt.executeQuery(qry); String Columnames[] = { "user_id", "business_id", "text" }; DefaultTableModel dtm = (DefaultTableModel) jTable2.getModel(); dtm.setColumnCount(0); dtm.setRowCount(0); int numberOfColumns = Columnames.length; for (int i = 0; i < numberOfColumns; i++) { String name = Columnames[i]; dtm.addColumn(name); } cursor2.forEach(new Block<Document>() { @Override public void apply(final Document document) { Object rowData[] = new Object[numberOfColumns]; rowData[0] = document.get("user_id"); rowData[1] = document.get("business_id"); rowData[2] = document.get("text"); dtm.addRow(rowData); rowData = null; } }); }
From source file:hw.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed MongoCollection<Document> coll = db.getCollection("user"); String member_value = jTextField2.getText(); String review_value = jTextField4.getText(); String fans_value = jTextField5.getText(); String average_stars_value = jTextField6.getText(); String friends_value = jTextField7.getText(); String review_dropdown = jComboBox13.getSelectedItem().toString(); String fans_dropdown = jComboBox14.getSelectedItem().toString(); String stars_dropdown = jComboBox15.getSelectedItem().toString(); String friends_dropdown = jComboBox16.getSelectedItem().toString(); BasicDBObject qryUser = new BasicDBObject(); BasicDBList UserList = new BasicDBList(); FindIterable<Document> cursor; String select = jComboBox1.getSelectedItem().toString(); if (member_value == null && review_value.equals("0") && fans_value.equals("0") && average_stars_value.equals("0") && friends_value.equals("0")) { qryUser = null;//from w ww . jav a2 s. c om } if (member_value == null || member_value.equals("")) { member_value = "1999-01"; } // if(review_value == null || review_value.equals("")) // { // review_value = "0"; // } // if(fans_value == null || fans_value.equals("")) // { // fans_value = "0"; // } // if(average_stars_value == null || average_stars_value.equals("")) // { // average_stars_value = "0"; // } // if(friends_value == null || friends_value.equals("")) // { // friends_value = "0"; // } if (!friends_value.equals("0")) { BasicDBObject fv = new BasicDBObject("friends." + friends_value, new BasicDBObject("$exists", true)); UserList.add(fv); } if (!member_value.equals("0")) { BasicDBObject mv = new BasicDBObject("yelping_since", new BasicDBObject("$gt", member_value)); UserList.add(mv); } if (!review_value.equals("0")) { if (review_dropdown.equals(">")) { BasicDBObject rv = new BasicDBObject("review_count", new BasicDBObject("$gt", Integer.parseInt(review_value))); UserList.add(rv); } if (review_dropdown.equals("<")) { BasicDBObject rv = new BasicDBObject("review_count", new BasicDBObject("$lt", Integer.parseInt(review_value))); UserList.add(rv); } if (review_dropdown.equals("=")) { BasicDBObject rv = new BasicDBObject("review_count", Integer.parseInt(review_value)); UserList.add(rv); } } if (!fans_value.equals("0")) { if (fans_dropdown.equals(">")) { BasicDBObject f = new BasicDBObject("fans", new BasicDBObject("$gt", Integer.parseInt(fans_value))); UserList.add(f); } if (review_dropdown.equals("<")) { BasicDBObject f = new BasicDBObject("fans", new BasicDBObject("$lt", Integer.parseInt(fans_value))); UserList.add(f); } if (review_dropdown.equals("=")) { BasicDBObject f = new BasicDBObject("fans", Integer.parseInt(fans_value)); UserList.add(f); } } if (!average_stars_value.equals("0")) { if (stars_dropdown.equals(">")) { BasicDBObject as = new BasicDBObject("average_stars", new BasicDBObject("$gt", Integer.parseInt(average_stars_value))); UserList.add(as); } if (review_dropdown.equals("<")) { BasicDBObject as = new BasicDBObject("average_stars", new BasicDBObject("$lt", Integer.parseInt(average_stars_value))); UserList.add(as); } if (review_dropdown.equals("=")) { BasicDBObject as = new BasicDBObject("average_stars", Integer.parseInt(average_stars_value)); UserList.add(as); } } if ("AND".equals(jComboBox1.getSelectedItem().toString())) { qryUser = new BasicDBObject("$and", UserList); } if ("OR".equals(jComboBox1.getSelectedItem().toString())) { qryUser = new BasicDBObject("$or", UserList); } if (qryUser == null) { jTextField8.setText("db.user.find()"); cursor = coll.find(); } else { jTextField8.setText("db.user.find(" + qryUser.toString() + ")"); cursor = coll.find(qryUser); } String Columnames[] = { "yelping_since", "review_count", "name", "user_id", "average_stars" }; DefaultTableModel dtm = (DefaultTableModel) jTable2.getModel(); dtm.setColumnCount(0); dtm.setRowCount(0); int numberOfColumns = Columnames.length; for (int i = 0; i < numberOfColumns; i++) { String name = Columnames[i]; dtm.addColumn(name); } cursor.forEach(new Block<Document>() { @Override public void apply(final Document document) { Object rowData[] = new Object[numberOfColumns]; rowData[0] = document.get("yelping_since"); rowData[1] = document.get("review_count"); rowData[2] = document.get("name"); rowData[3] = document.get("user_id"); rowData[4] = document.get("average_stars"); // System.out.print(document.get("yelping_since")+"\t"); // System.out.print(document.get("review_count")+"\t"); // System.out.print(document.get("name")+"\t"); // System.out.print(document.get("user_id")+"\t"); // System.out.print(document.get("average_stars")+"\t"); // System.out.println(); dtm.addRow(rowData); rowData = null; } }); jTable2.setRowSelectionAllowed(true); jTable2.setModel(dtm); jTable2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); dtm.fireTableDataChanged(); // mongoClient.close(); // // // }
From source file:grupob.TipoProceso.java
private void agregarDatos() { DefaultTableModel modelo = (DefaultTableModel) jTableRegiones.getModel(); modelo.setRowCount(0); String datos[] = new String[3]; for (int i = 0; i < listaRegiones.size(); i++) { datos[0] = listaRegiones.get(i).getNombre(); if (listaRegiones.get(i).getCantidadVotantesRegistrados() == 0) { datos[1] = ""; } else {//w ww .j av a2s. com datos[1] = Long.toString(listaRegiones.get(i).getCantidadVotantesRegistrados()); } modelo.addRow(datos); } TableColumn colum1 = null; colum1 = jTableRegiones.getColumnModel().getColumn(0); colum1.setPreferredWidth(60); TableColumn colum2 = null; colum2 = jTableRegiones.getColumnModel().getColumn(1); colum2.setPreferredWidth(5); TableColumn colum3 = null; colum3 = jTableRegiones.getColumnModel().getColumn(2); colum3.setPreferredWidth(40); colum3.setPreferredWidth(10); }
From source file:grupob.TipoProceso.java
private void agregarDatosDistritos() { DefaultTableModel modelo = (DefaultTableModel) jTableDistritos.getModel(); modelo.setRowCount(0); String datos[] = new String[4]; for (int i = 0; i < listaDistritos.size(); i++) { datos[0] = listaDistritos.get(i).getNombre(); if (listaDistritos.get(i).getCantidadVotantesRegistrados() == 0) { datos[1] = ""; } else {/* ww w . j a v a 2s .c om*/ datos[1] = Long.toString(listaDistritos.get(i).getCantidadVotantesRegistrados()); } String n = Manager.queryByIdRegion(listaDistritos.get(i).getIdRegion()).getNombre(); datos[2] = "" + n; modelo.addRow(datos); } TableColumn colum1 = null; colum1 = jTableDistritos.getColumnModel().getColumn(0); colum1.setPreferredWidth(60); TableColumn colum2 = null; colum2 = jTableDistritos.getColumnModel().getColumn(1); colum2.setPreferredWidth(5); TableColumn colum3 = null; colum3 = jTableDistritos.getColumnModel().getColumn(2); colum3.setPreferredWidth(5); TableColumn colum4 = null; colum4 = jTableDistritos.getColumnModel().getColumn(3); colum4.setPreferredWidth(40); colum4.setPreferredWidth(10); }
From source file:grupob.TipoProceso.java
private void buscarRegionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarRegionesActionPerformed ArrayList<Region> listaBuscada = new ArrayList<Region>(); String busc = textRegiones.getText(); if (busc.compareTo("") == 0) { listaBuscada = Manager.queryAllRegion(); } else {/*from w ww .j a va2 s. c o m*/ listaBuscada = Manager.queryByNameRegion(busc); } DefaultTableModel modelo = (DefaultTableModel) jTableRegiones.getModel(); modelo.setRowCount(0); String datos[] = new String[3]; for (int i = 0; i < listaBuscada.size(); i++) { datos[0] = listaBuscada.get(i).getNombre(); if (listaBuscada.get(i).getCantidadVotantesRegistrados() == 0) { datos[1] = ""; } else { datos[1] = Long.toString(listaBuscada.get(i).getCantidadVotantesRegistrados()); } modelo.addRow(datos); } TableColumn colum1 = null; colum1 = jTableRegiones.getColumnModel().getColumn(0); colum1.setPreferredWidth(60); TableColumn colum2 = null; colum2 = jTableRegiones.getColumnModel().getColumn(1); colum2.setPreferredWidth(5); TableColumn colum3 = null; colum3 = jTableRegiones.getColumnModel().getColumn(2); colum3.setPreferredWidth(40); colum3.setPreferredWidth(10); listaRegiones = listaBuscada; }
From source file:grupob.TipoProceso.java
private void buscarDistritosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarDistritosActionPerformed ArrayList<Distrito> listaBuscada = new ArrayList<Distrito>(); String busc = textDistrito.getText(); if (busc.compareTo("") == 0) { listaBuscada = Manager.queryAllDistrito(); } else {/* w ww .j ava 2s . co m*/ listaBuscada = Manager.queryByNameDistrito(busc); } DefaultTableModel modelo2 = (DefaultTableModel) jTableDistritos.getModel(); modelo2.setRowCount(0); String datos[] = new String[3]; for (int i = 0; i < listaBuscada.size(); i++) { datos[0] = listaBuscada.get(i).getNombre(); if (listaBuscada.get(i).getCantidadVotantesRegistrados() == 0) { datos[1] = ""; } else { datos[1] = Long.toString(listaBuscada.get(i).getCantidadVotantesRegistrados()); } Distrito s = listaBuscada.get(i); String n = Manager.queryByIdRegion(s.getIdRegion()).getNombre(); datos[2] = "" + n; modelo2.addRow(datos); } TableColumn colum1 = null; colum1 = jTableDistritos.getColumnModel().getColumn(0); colum1.setPreferredWidth(60); TableColumn colum2 = null; colum2 = jTableDistritos.getColumnModel().getColumn(1); colum2.setPreferredWidth(5); TableColumn colum3 = null; colum3 = jTableDistritos.getColumnModel().getColumn(2); colum3.setPreferredWidth(5); TableColumn colum4 = null; colum4 = jTableDistritos.getColumnModel().getColumn(3); colum4.setPreferredWidth(40); colum4.setPreferredWidth(10); listaDistritos = listaBuscada; }