List of usage examples for javax.swing.table DefaultTableModel fireTableDataChanged
public void fireTableDataChanged()
From source file:org.dc.file.search.ui.DashboardForm.java
private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchActionPerformed int hopCount = DEFAULT_SEARCH_HOPE_COUNT; int timeout = DEFAULT_SEARCH_TIMEOUT_SEC; if (advancedSearchEnabled) { try {//from www .j a v a 2 s . c om hopCount = Integer.parseInt(txtHopCount.getText()); timeout = Integer.parseInt(txtTimeoutSec.getText()); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(this, "Default search options will be used", "Invalid Search Options!", JOptionPane.ERROR_MESSAGE); } } Store store = Store.getInstance(); String key = txtSearchKey.getText(); Peer localPeer = store.getLocalPeer(); SearchRequest searchRequest = new SearchRequest(Calendar.getInstance().getTimeInMillis(), key, hopCount, localPeer); store.setMySearchRequest(searchRequest); store.addSearchRequest(searchRequest); store.setSearchResults(new ArrayList<>()); List<DFile> results = Store.getInstance().findInFiles(searchRequest.getSearchKey()); if (!results.isEmpty()) { SearchResult searchResult = new SearchResult(key, localPeer, 0, results); store.addSearchResult(searchResult); } for (Map.Entry<String, Peer> entry : Store.getInstance().getPeerMap().entrySet()) { Peer peer = entry.getValue(); MessageUtils.sendUDPMessage(peer.getIp(), peer.getPort(), MessageType.SER + " " + localPeer.getIp() + " " + localPeer.getPort() + " \"" + key + "\" 2"); } Runnable resultTask = () -> { try { List<SearchResult> searchResults = Store.getInstance().getSearchResults(); resultFiles = new HashMap<>(); if (searchResults != null) { DefaultTableModel model = (DefaultTableModel) tblSearchResults.getModel(); model.setRowCount(0); for (int i = 0; i < searchResults.size(); i++) { Object[] data = new Object[MAX_COLS]; SearchResult searchResult = searchResults.get(i); Peer peer = searchResult.getPeerWithResults(); data[0] = peer.getKey(); data[1] = searchResult.getHopCount(); for (DFile dFile : searchResult.getResults()) { data[2] = dFile.getFileName(); data[3] = new StarRater(5, dFile.getTotalRating(), 0); resultFiles.put(dFile.getFileName(), dFile); model.addRow(data); } } tblSearchResults.setModel(model); model.fireTableDataChanged(); } } catch (Throwable t) { System.out.println(t.getMessage()); } finally { btnSearch.setEnabled(true); } }; initSearchResultsTable(); initCommentResultsTable(); btnSearch.setEnabled(false); tblSearchResults.setVisible(true); ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.schedule(resultTask, timeout, TimeUnit.SECONDS); resetAndStartProgress(timeout); }
From source file:tk.egsf.ddns.janela.java
private void JBatualizalistaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBatualizalistaActionPerformed String https_url = "https://ddns.egsf.tk/webservice/gethosts"; String gethostsjson = JSON_helper.getJsonUrl(https_url, ddns.getBasicAuth()); if (gethostsjson == "") { return;/*ww w .j a v a2 s . c om*/ } JSONArray jsa = new JSONArray(gethostsjson); DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); List<Boolean> selected = new ArrayList<Boolean>(); int rowcount = jTable1.getRowCount(); for (int i = 0; i < rowcount; i++) { selected.add((Boolean) jTable1.getValueAt(i, 2)); } model.setNumRows(0); try { for (int i = 0; i < jsa.length(); i++) { System.out.println(jsa.get(i)); JSONObject js = jsa.getJSONObject(i); Object[] row = new Object[] { js.getString("host") + "." + js.getString("zone"), js.getString("ip") }; model.addRow(row); } model.fireTableDataChanged(); for (int i = 0; i < selected.size(); i++) { Boolean boolean1 = selected.get(i); jTable1.setValueAt(boolean1, i, 2); } } catch (Exception e) { System.out.println("Erro: " + e.getMessage()); } }
From source file:us.vicentini.domainutil.view.DomainPanel.java
@Override public void newResults(String domainName, Record[] records) { String text = ""; for (int i = 0; i < records.length; i++) { Record mx = records[i];/*from w w w .ja v a 2s .c om*/ if (mx.getType() == org.xbill.DNS.Type.MX) { text = ((MXRecord) mx).getTarget().toString(true); } else { text = mx.toString(); } } for (int i = 0; i < dataModel.length; i++) { if (domainName.equals(dataModel[i][0])) { log.info("[result] " + domainName + ": " + text); ((MyString) dataModel[i][2]).setText(text); } } DefaultTableModel tableModel = ((DefaultTableModel) jTable1.getModel()); tableModel.fireTableDataChanged(); }
From source file:us.vicentini.domainutil.view.DomainPanel.java
@Override public void newStatus(String domainName, ELookupStatus eLookupStatus) { for (int i = 0; i < dataModel.length; i++) { if (domainName.equals(dataModel[i][0])) { log.info("[status] " + domainName + ": " + eLookupStatus.toString()); ((MyString) dataModel[i][1]).setText(eLookupStatus.toString()); }/*from w w w . j av a 2 s . co m*/ } DefaultTableModel tableModel = ((DefaultTableModel) jTable1.getModel()); tableModel.fireTableDataChanged(); }