List of usage examples for javax.swing.table DefaultTableModel addRow
public void addRow(Object[] rowData)
From source file:br.com.atmatech.sac.view.ViewListaAtendimento.java
public void buscaAtendimento() { String status = "'ABERTO','INICIADO','PENDENTE'"; Integer idtecnico = new UsuarioLogadoBeans().getIdusuario(); Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -30); Date ini = c.getTime();//from ww w. j a v a2 s . c o m Date fin = new Timestamp(new Date().getTime()); String campo = "dtabertura"; List<AtendimentoBeans> labt = new ArrayList<>(); DefaultTableModel tabelaatendimento = (DefaultTableModel) jTatendimento.getModel(); try { labt = new AtendimentoDao().getAtendimento(getTipoSelected(), status, idtecnico, new UsuarioLogadoBeans().getVchamados(), ini, fin, getTipoData()); if (!caparaArrayList(labt, lab)) { lab = labt; tabelaatendimento.setNumRows(0); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); TableCellRenderer renderer = new PintarLinhasTabelaAtend(false); jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer); for (AtendimentoBeans ab : lab) { tabelaatendimento.addRow( new Object[] { ab.getIDATENDIMENTO(), ab.getRazao(), sdf.format(ab.getDTABERTURA()), ab.getTecniconome(), ab.getAberturanome(), ab.getSTATUS(), ab.getTIPO() }); } } } catch (SQLException ex) { lab.clear(); tabelaatendimento.setNumRows(0); //Logger.getLogger(ViewListaAtendimento.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.agmip.ui.afsirs.frames.SWFrame.java
private void soilNameComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_soilNameComboActionPerformed // TODO add your handling code here: if (isInitializing) return;//from w w w.j a v a2s . c o m int index = soilNameCombo.getSelectedIndex(); if (index == -1) return; //index = index ==-1? 0 : index; SoilData soilData = utils.getSoilData(); String key = (String) soilFileListCombo.getSelectedItem(); key = key.trim(); ArrayList<Soil> soilList = soilData.getSoilsFromFile(key); if (soilList.size() > 0) { if (index == -1) { // TODO add your handling code here: DefaultTableModel model = (DefaultTableModel) soilTable.getModel(); int row = model.getRowCount(); for (int i = 0; i < row; i++) { model.removeRow(0); } index = 0; Soil soil = soilList.get(index); for (int i = 0; i < soil.getNL(); i++) { Object[] vec = new Object[4]; vec[0] = i + 1; vec[1] = soil.getDU()[i]; vec[2] = soil.getWC()[i]; vec[3] = soil.getWCU()[i] - soil.getWCL()[i]; model.addRow(vec); } } else { // This is to take the backup of the data so that I can //Soil soil = soilList.get(selectedSoilIndex); 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); } } int row = model.getRowCount(); for (int i = 0; i < row; i++) { model.removeRow(0); } Soil soil = soilList.get(index); DU = soil.getDU(); WCL = soil.getWCL(); WCU = soil.getWCU(); WC = soil.getWC(); NL = soil.getNL(); SNAME = soil.getName(); utils.setDefaultSoil(soil); for (int i = 0; i < soil.getNL(); i++) { Object[] vec = new Object[4]; vec[0] = i + 1; vec[1] = soil.getDU()[i]; vec[2] = soil.getWC()[i]; vec[3] = (WCU[i] - WCL[i]); model.addRow(vec); } prevSoil = soil; } } //selectedSoilIndex = index; }
From source file:gdt.jgui.entity.fields.JFieldsEditor.java
private void deleteRows() { try {//from w w w . j a va 2 s. co m JTable table = (JTable) scrollPane.getViewport().getView(); DefaultTableModel tableModel = (DefaultTableModel) table.getModel(); ListSelectionModel listModel = table.getSelectionModel(); int rCnt = table.getRowCount(); ArrayList<Integer> srl = new ArrayList<Integer>(); for (int i = 0; i < rCnt; i++) if (listModel.isSelectedIndex(i)) { srl.add(new Integer(i)); } Integer[] sra = srl.toArray(new Integer[0]); ArrayList<Core> ol = new ArrayList<Core>(); Core row; boolean skip; for (int i = 0; i < rCnt; i++) { skip = false; for (int aSra : sra) { if (i == aSra) { skip = true; break; } } if (!skip) { row = new Core(null, (String) tableModel.getValueAt(i, 0), (String) tableModel.getValueAt(i, 1)); ol.add(row); } } Core[] ra = ol.toArray(new Core[0]); while (tableModel.getRowCount() > 0) tableModel.removeRow(0); for (Core aRa : ra) { tableModel.addRow(new String[] { aRa.name, aRa.value }); } } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.BeanInspectorPanel.java
@SuppressWarnings("unchecked") private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed DefaultTableModel dtm = (DefaultTableModel) getJTableFields().getModel(); TreePath[] paths = jTree1.getSelectionPaths(); if (paths == null) return;//from w w w .j a v a 2 s . co m for (int i = 0; i < paths.length; ++i) { boolean valid = true; TreePath tp = paths[i]; TreeJRField tjrf = (TreeJRField) ((DefaultMutableTreeNode) tp.getLastPathComponent()).getUserObject(); String returnType = Misc.getJRFieldType(tjrf.getObj().getName()); JRDesignField field = new JRDesignField(); field.setName(tjrf.getField().getName()); field.setValueClassName(returnType); field.setDescription(tjrf.getField().getDescription()); Vector row = new Vector(); row.addElement(field); row.addElement(field.getValueClassName()); row.addElement(field.getDescription()); if (isComboVisible() && jComboBox1.getSelectedItem() instanceof FieldClassWrapper) { FieldClassWrapper cw = (FieldClassWrapper) jComboBox1.getSelectedItem(); field.setName(cw.getFieldName() + "." + field.getDescription()); field.setDescription(field.getName()); } // Check for duplicates fields... boolean found = fieldAlreadyExists(field); String baseName = field.getName(); for (int j = 1; isPathOnDescription() && found; ++j) { field.setName(baseName + "_" + j); found = fieldAlreadyExists(field); } if (!found) { dtm.addRow(row); getJTableFields().getSelectionModel().addSelectionInterval(getJTableFields().getRowCount() - 1, getJTableFields().getRowCount() - 1); } } }
From source file:br.com.atmatech.sac.view.ViewListaAtendimento.java
public void buscaAtendimento(String tipo, final String status, final Integer idtecnico, final Date ini, final Date fin, String campo) { new Thread(new Runnable() { @Override//w ww . java 2s .c om public void run() { showAguarde(); } }).start(); DefaultTableModel tabelaatendimento = (DefaultTableModel) jTatendimento.getModel(); tabelaatendimento.setNumRows(0); try { lab = new AtendimentoDao().getAtendimento(tipo, status, idtecnico, new UsuarioLogadoBeans().getVchamados(), ini, fin, getTipoData()); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Erro ao consultar Atendimento\n" + ex, "Atendimento", JOptionPane.ERROR_MESSAGE); jDaguarde.setVisible(false); } SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); TableCellRenderer renderer = new PintarLinhasTabelaAtend(false); jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer); for (AtendimentoBeans ab : lab) { tabelaatendimento .addRow(new Object[] { ab.getIDATENDIMENTO(), ab.getRazao(), sdf.format(ab.getDTABERTURA()), ab.getTecniconome(), ab.getAberturanome(), ab.getSTATUS(), ab.getTIPO() }); } jDaguarde.setVisible(false); }
From source file:de.tor.tribes.ui.views.DSWorkbenchReTimerFrame.java
private void startCalculation() { jideRetimeTabbedPane.setSelectedIndex(0); if (parsedAttack == null || parsedAttack.getSource() == null || parsedAttack.getTarget() == null || parsedAttack.getUnit() == null || parsedAttack.getArriveTime() == null) { JOptionPaneHelper.showInformationBox(this, "Bitte fge zuerst einen gltigen Angriff ein und whle eine Einheit", "Information"); return;//from w w w . jav a 2 s. com } jCalculationSettingsDialog.pack(); jCalculationSettingsDialog.setLocationRelativeTo(DSWorkbenchReTimerFrame.this); DefaultListModel tagModel = new DefaultListModel(); tagModel.addElement(NoTag.getSingleton()); for (ManageableType e : TagManager.getSingleton().getAllElements()) { tagModel.addElement((Tag) e); } jTagList.setModel(tagModel); jRelationBox.setSelected(true); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (UnitHolder unit : DataHolder.getSingleton().getUnits()) { model.addElement(unit); } jUnitBox.setModel(model); jUnitBox.setRenderer(new UnitListCellRenderer()); // <editor-fold defaultstate="collapsed" desc="Build attack plan table"> DefaultTableModel attackPlanTableModel = new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { "Angriffsplan", "Abgleichen" }) { Class[] types = new Class[] { String.class, Boolean.class }; @Override public Class getColumnClass(int columnIndex) { return types[columnIndex]; } @Override public boolean isCellEditable(int row, int col) { if (col == 0) { return false; } return true; } }; String[] plans = AttackManager.getSingleton().getGroups(); for (String plan : plans) { attackPlanTableModel.addRow(new Object[] { plan, false }); } jAttackPlanTable.setModel(attackPlanTableModel); DefaultTableCellRenderer headerRenderer = new SortableTableHeaderRenderer(); for (int i = 0; i < jAttackPlanTable.getColumnCount(); i++) { jAttackPlanTable.getColumn(jAttackPlanTable.getColumnName(i)).setHeaderRenderer(headerRenderer); } // </editor-fold> jCalculationSettingsDialog.setVisible(true); }
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 w w w . j a v a 2s . 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 a 2 s. c o 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:grupob.TipoProceso.java
private void agregarDatos() { DefaultTableModel modelo = (DefaultTableModel) jTableRegiones.getModel(); modelo.setRowCount(0);/*from www. j av a 2s . c om*/ 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 { 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 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 {/* w w w . j a v a2s .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; }