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
private void buscaAtendimento(String campo, String parametro, Integer idusuario, Boolean supervisor) { DefaultTableModel tabelaatendimento = (DefaultTableModel) jTatendimento.getModel(); tabelaatendimento.setNumRows(0);//from www .j av a 2 s . c o m //String status=verificaStatus(); lab = new AtendimentoDao().getAtendimento(verificaStatus(), campo, parametro, idusuario, supervisor, jDinicial.getDate(), jDfinal.getDate(), getTipoData()); 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() }); } jDconsulta.setVisible(false); }
From source file:gtu._work.ui.DirectoryCompareUI.java
/** * TODO/* w w w . j a v a2 s . c o m*/ */ private void compareStart() { try { String leftStr = leftDirText.getText(); String rightStr = rightDirText.getText(); Validate.notBlank(leftStr, "??"); Validate.notBlank(rightStr, "???"); initComponents(); File leftFile = new File(StringUtils.trim(leftStr)); File rightFile = new File(StringUtils.trim(rightStr)); if (!leftFile.exists()) { leftFile = File.createTempFile("left_", ".txt"); if (leftFile.exists()) { leftFile.delete(); } FileUtils.write(leftFile, leftStr, "utf8"); } if (!rightFile.exists()) { rightFile = File.createTempFile("right_", ".txt"); if (rightFile.exists()) { rightFile.delete(); } FileUtils.write(rightFile, rightStr, "utf8"); } File mainFile = leftFile; File compareFile = rightFile; modelOrignList.clear(); compareSearch = new MainCompareSearch(mainFile, compareFile) { @Override void compareFileNotExists(FileZ mainFile, FileZ compareToFile, boolean mainFileIsLeft) { modelOrignList .add(getCreateRow(mainFile, compareToFile, mainFileIsLeft, DiffMergeStatus.NOT_EXISTS)); } @Override void sameFile(FileZ mainFile, FileZ compareToFile, boolean mainFileIsLeft) { modelOrignList.add(getCreateRow(mainFile, compareToFile, mainFileIsLeft, DiffMergeStatus.SAME)); } @Override void differentFile(FileZ mainFile, FileZ compareToFile, boolean mainFileIsLeft) { modelOrignList .add(getCreateRow(mainFile, compareToFile, mainFileIsLeft, DiffMergeStatus.DIFFERENT)); } @Override void complete() { DefaultTableModel dirCompareModel = getDefaultTableModel(); DefaultComboBoxModel extensionModel = new DefaultComboBoxModel(); Set<String> extensionSet = new TreeSet<String>(); for (Object[] rows : modelOrignList) { dirCompareModel.addRow(rows); InfoObj infoObj = (InfoObj) rows[0]; // ??? checkExtensionName(infoObj, extensionSet); } extensionModel.addElement(EXTENSION_ALL); extensionModel.addElement(EXTENSION_CUSTOM); for (String name : extensionSet) { extensionModel.addElement(name); } while (extensionNameComboBox.getModel().getSize() != extensionModel.getSize()) { extensionNameComboBox.setModel(extensionModel); System.out.println("reset extensionNameComboBox"); } while (dirCompareTable.getModel().getRowCount() != dirCompareModel.getRowCount()) { dirCompareTable.setModel(dirCompareModel); System.out.println("reset dirCompareTable"); } System.out.println( "extensionNameComboBox = " + (extensionNameComboBox.getModel() == extensionModel)); System.out.println("dirCompareTable = " + (dirCompareTable.getModel() == dirCompareModel)); System.out.println("extensionNameComboBox = " + extensionNameComboBox.getModel().getSize()); System.out.println("dirCompareTable = " + dirCompareTable.getModel().getRowCount()); setTitle(":" + mainFileCount + "/?:" + compareToFileCount + ", :" + completeTime); JCommonUtil._jOptionPane_showMessageDialog_info(// "???" + // "\n?:" + this.countSameFile + // "\n??:" + this.countDifferentFile + // "\n?:" + this.countNotExists + // "\n:" + completeTime + // "\n?merge:" + modelOrignList.size()); } }; if (leftFile.isDirectory() && rightFile.isDirectory()) { if (StringUtils.equals(FINDFUNCTION_ABS, String.valueOf(compareStyleComboBox.getSelectedItem()))) { compareSearch.executeSameDirectory(); } else if (StringUtils.equals(FINDFUNCTION_REL, String.valueOf(compareStyleComboBox.getSelectedItem()))) { List<File> mainFileList = new ArrayList<File>(); List<File> compareFileList = new ArrayList<File>(); FileUtil.searchFilefind(mainFile, ".*", mainFileList); FileUtil.searchFilefind(compareFile, ".*", compareFileList); compareSearch.executeTwoDirectoryButNotSame(mainFileList, compareFileList); } else { Validate.isTrue(false, "??!"); } } else if (leftFile.isFile() && rightFile.isFile()) { compareSearch.executeTwoFile(); } else if (leftFile.isDirectory() && rightFile.isFile()) { List<File> mainFileList = new ArrayList<File>(); List<File> compareFileList = new ArrayList<File>(); FileUtil.searchFilefind(mainFile, ".*", mainFileList); compareFileList.add(compareFile); compareSearch.executeTwoDirectoryButNotSame(mainFileList, compareFileList); compareStyleComboBox.setSelectedItem(FINDFUNCTION_REL); } else if (leftFile.isFile() && rightFile.isDirectory()) { List<File> mainFileList = new ArrayList<File>(); List<File> compareFileList = new ArrayList<File>(); mainFileList.add(mainFile); FileUtil.searchFilefind(compareFile, ".*", compareFileList); compareSearch.executeTwoDirectoryButNotSame(mainFileList, compareFileList); compareStyleComboBox.setSelectedItem(FINDFUNCTION_REL); } else { Validate.isTrue(false, "???!"); } } catch (Exception ex) { JCommonUtil.handleException(ex, false); } }
From source file:userinterface.DoctorWorkArea.DiagnosePatientJPanel.java
public void populateDietRequestTable() { DefaultTableModel model = (DefaultTableModel) dietRequestJTable.getModel(); model.setRowCount(0);/*from ww w .j a v a 2 s .c o m*/ DietitianWorkRequest req = null; for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) { if (request instanceof DietitianWorkRequest) { Object[] row = new Object[5]; row[0] = request; row[1] = request.getMessage(); row[2] = request.getReceiver(); row[3] = request.getStatus(); String result = ((DietitianWorkRequest) request).getResult(); row[4] = result == null ? "Waiting" : result; model.addRow(row); } } }
From source file:dataviewer.DataViewer.java
private void transpose(DefaultTableModel model) { try {/*from w ww. ja va2 s . com*/ if (model.getColumnCount() == 0) { return; } DefaultTableModel new_model = new DefaultTableModel(); // if not transposed if (!model.getColumnName(0).equals("_field_") && transpose == true) { new_model.addColumn("_field_"); for (int r = 1; r <= model.getRowCount(); ++r) { new_model.addColumn("_col_" + r); } long n = 1; for (int c = 0; c < model.getColumnCount(); ++c) { Object[] s = new Object[new_model.getColumnCount()]; String colname = model.getColumnName(c); int l = 0; s[l++] = colname; for (int r = 0; r < model.getRowCount(); ++r) { s[r + l] = model.getValueAt(r, c); } new_model.addRow(s); } } if (model.getColumnName(0).equals("_field_") && transpose == false) { // if transposed for (int r = 0; r < model.getRowCount(); ++r) { new_model.addColumn(model.getValueAt(r, 0)); } List<Integer> colIdx = new ArrayList(); for (int c = 0; c < model.getColumnCount(); ++c) { if (!model.getColumnName(c).equals("_field_")) { colIdx.add(c); } } for (int c = 0; c < colIdx.size(); ++c) { Object[] s = new Object[new_model.getColumnCount()]; for (int r = 0; r < model.getRowCount(); ++r) { s[r] = model.getValueAt(r, colIdx.get(c)); } new_model.addRow(s); } } renderData(new_model); } catch (Exception e) { txt_count.setText(e.getMessage()); } }
From source file:Interface.FramePrincipal.java
private void bt_atuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_atuActionPerformed ///////////////////////////////////////////// Baixa xml do bucket ////////////////////////////////////////////////////////// File diretorio = new File(dir_dow.getText()); if ("".equals(dir_dow.getText())) { JOptionPane.showMessageDialog(null, "Campo diretrio deve ser preenchido!"); } else if (!diretorio.exists()) { JOptionPane.showMessageDialog(null, "Este no um diretrio vlido!"); } else {/*from w w w .j a v a 2 s . co m*/ try { URL arquivoBucket = new URL("http://storage.googleapis.com/" + bac.getNome()); //Passa caminho de saida do arquivo que esta sendo baixado ReadableByteChannel canalArquivoSaida = Channels.newChannel(arquivoBucket.openStream()); FileOutputStream arquivoSaida = new FileOutputStream( dir_dow.getText() + "/" + bac.getNome() + ".xml"); //Calcula tempo que o processo de download levou long inicio = System.currentTimeMillis(); arquivoSaida.getChannel().transferFrom(canalArquivoSaida, 0, 1 << 24); long fim = System.currentTimeMillis(); System.out.println(fim - inicio); arquivoSaida.close(); //libera o arquivo aps ser baixado. /////////////////////////////// Carrega tabela com nome de arquivos //////////////////////////////////////////////////// //percorret tabela DefaultTableModel adm = (DefaultTableModel) jTable.getModel(); adm.setNumRows(0); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Importar arquivo xml File file = new File(dir_dow.getText() + "/" + bac.getNome() + ".xml"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(file); doc.getDocumentElement().normalize(); System.out.println("Root element " + doc.getDocumentElement().getNodeName()); NodeList nodeLst = doc.getElementsByTagName("Contents"); System.out.println("Information of all employees"); for (int s = 0; s < nodeLst.getLength(); s++) { Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element fstElmnt = (Element) fstNode; NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("Key"); Element fstNmElmnt = (Element) fstNmElmntLst.item(0); NodeList fstNm = fstNmElmnt.getChildNodes(); System.out.println("Key : " + ((Node) fstNm.item(0)).getNodeValue()); String val = ((Node) fstNm.item(0)).getNodeValue(); adm.addRow(new Object[] { val }); } } } catch (Exception e) { e.printStackTrace(); } } }
From source file:megacasting.view.StatistiqueForm.java
/** * Charge les lignes du tableau domaine/* w ww .j a v a 2 s.c om*/ * Nom du domaine X, Nb de mtiers du domaine X, Nb d'offres du domaine X, Nb de postes du domaine X */ private void refreshTableDomaine() { // On rcupre le model DefaultTableModel model = (DefaultTableModel) tableDomaine.getModel(); // Liste de tous les domaines ArrayList<Domaine> domaines = DomaineDAO.lister(mainJFrame.cnx); ArrayList<Metier> metiers = new ArrayList<>(); // Vide les lignes model.setRowCount(0); // Pour chaque domaine for (Domaine d : domaines) { // Liste des mtiers du domaine metiers = MetierDAO.lister(mainJFrame.cnx, d); // Liste des offres du domaine (celles qui n'ont pas de mtier) ArrayList<Offre> offresFinal = OffreDAO.lister(mainJFrame.cnx, d, null); // On initialise le nb de postes 0 int nbPostes = 0; // Pour chaque mtier for (Metier m : metiers) { // Liste des offres du mtier (et donc du domaine) ArrayList<Offre> offresTemp = OffreDAO.lister(mainJFrame.cnx, m); // Pour chaque offre du mtier for (Offre o : offresTemp) { // On l'ajoute la liste des offres du domaine offresFinal.add(o); } } // Pour chaque offre du domaine for (Offre of : offresFinal) { // On compte le nombre de postes nbPostes += of.getNbPoste(); } // On ajoute la ligne dans le model model.addRow(new Object[] { // Libelle du domaine d.getLibelle(), // Nombre de mtiers dans ce domaine metiers.size(), // Nombre d'offres pour ce domaine offresFinal.size(), // Nombre de postes pour ce domaine nbPostes }); } }
From source file:gdt.jgui.entity.query.JQueryPanel.java
private void showContent() { try {//from w w w. j a va 2 s . com String[] sa = select(); Entigrator entigrator = console.getEntigrator(entihome$); Sack query = entigrator.getEntityAtKey(entityKey$); ArrayList<String> sl = new ArrayList<String>(); String label$; for (String s : sa) { label$ = entigrator.indx_getLabel(s); if (label$ == null) { System.out.println("JQueryPanel:showContent:cannot get label for key=" + s); continue; } sl.add(label$); } Collections.sort(sl); Sack entity; String entity$; String[] row; StringBuffer sb; int num = 0; DefaultTableModel model = (DefaultTableModel) table.getModel(); for (String s : sl) { // System.out.println("JQueryPanel:showContent:label="+s); entity$ = entigrator.indx_keyAtLabel(s); entity = entigrator.getEntityAtKey(entity$); if (entity == null) { System.out.println("JQueryPanel:showContent:cannot get entity=" + entity$); continue; } row = getRow(entity, query, num++); if (row == null) { System.out.println("JQueryPanel:showContent:cannot get row num=" + num); continue; } model.addRow(row); sb = new StringBuffer(); for (String r : row) sb.append(r + ";"); // System.out.println("JQueryPanel:showContent:"+sb.toString()); } } catch (Exception e) { LOGGER.severe(e.toString()); } }
From source file:dataviewer.DataViewer.java
private void cb_tableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_tableActionPerformed try {//from w w w .j a va 2s . c o m table = cb_table.getSelectedItem().toString(); DB db = new DB("./db/" + table + ".db"); db.open(); String[] cols = db.get_table_columns(table); db.close(); DefaultTableModel model = new DefaultTableModel(); //model.addColumn("Column Index"); model.addColumn("Field"); int i = 1; StyleContext sc = StyleContext.getDefaultStyleContext(); TabSet tabs = new TabSet(new TabStop[] { new TabStop(20) }); AttributeSet paraSet = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabs); tp_sql.setParagraphAttributes(paraSet, false); StyledDocument doc = tp_sql.getStyledDocument(); doc.remove(0, doc.getLength()); doc.insertString(doc.getLength(), "SELECT", null); doc.insertString(doc.getLength(), "\n", null); for (int j = 1; j < cols.length; ++j) { String s = cols[j]; //model.addRow(new Object[]{i++, s}); model.addRow(new Object[] { s }); doc.insertString(doc.getLength(), "\t", null); doc.insertString(doc.getLength(), s, null); if (j < cols.length - 1) { doc.insertString(doc.getLength(), ",", null); } doc.insertString(doc.getLength(), "\n", null); } doc.insertString(doc.getLength(), "FROM", null); doc.insertString(doc.getLength(), "\n", null); doc.insertString(doc.getLength(), "\t", null); doc.insertString(doc.getLength(), table, null); /*doc.insertString(doc.getLength(), "\n", null); doc.insertString(doc.getLength(), "WHERE", null); doc.insertString(doc.getLength(), "\n", null); doc.insertString(doc.getLength(), "\t", null); doc.insertString(doc.getLength(), "_N_ <= " + N, null); doc.insertString(doc.getLength(), ";", null);*/ tb_columns.setModel(model); TableRowSorter trs = new TableRowSorter(model); trs.setComparator(0, new IntComparator()); tb_columns.setRowSorter(trs); //highline(); } catch (Exception e) { txt_count.setText(e.getMessage()); } }
From source file:com.smanempat.view.ViewClassification.java
private void tampilKeTabel(String[] finalClass, int rowCountData) { DefaultTableModel tableModelResult = new DefaultTableModel(); tableModelResult = (DefaultTableModel) tableResult.getModel(); int jumlahSiswaIPA = 0; int jumlahSiswaIPS = 0; for (int i = 0; i < rowCountData; i++) { if (finalClass[i].equals("IPA")) { jumlahSiswaIPA = jumlahSiswaIPA + 1; } else if (finalClass[i].equalsIgnoreCase("IPS")) { jumlahSiswaIPS = jumlahSiswaIPS + 1; }/*w w w. j a va 2s . com*/ 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 = finalClass[i]; Object[] resultData = { nis, nama, jenKel, nilaiUN, ptBindo, ptMtk, ptBing, ptIpa, minat, jurusan }; tableModelResult.addRow(resultData); } jTabbedPane1.setSelectedIndex(1); labelKeterangan.setText("Hasil Klasifikasi Penjurusan Siswa Pada Tahun Ajaran " + jYearChooser1.getYear() + "/" + jYearChooser2.getYear() + ", dengan kriteria manual adalah sebagai berikut "); labelSiswaIPA.setText(jumlahSiswaIPA + ""); labelSiswaIPS.setText(jumlahSiswaIPS + ""); System.out.println("Jumlah IPA " + jumlahSiswaIPA); System.out.println("Jumlah IPS " + jumlahSiswaIPS); }
From source file:gdt.jgui.tool.JEntityEditor.java
private void deleteRows() { try {//from ww w .j a v a 2 s .c om JScrollPane scrollPane = (JScrollPane) tabbedPane.getSelectedComponent(); 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((String) tableModel.getValueAt(i, 0), (String) tableModel.getValueAt(i, 1), (String) tableModel.getValueAt(i, 2)); 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.type, aRa.name, aRa.value }); } } catch (Exception e) { LOGGER.severe(e.toString()); } }