java - 在 getValueAt 上执行查询并异步返回结果

标签 java swing asynchronous jtable abstracttablemodel

我正在实现一个包含大量数据的swing jtable,我希望在数据模型中的getValueAt时刻加载数据并在单元格中打印“Loading”并稍后返回数据,我不想在 UI 线程中执行查询。有什么想法吗?谢谢。

最佳答案

I am implementing a swing jtable with a huge number of data, i want the data to be loaded at the moment of getValueAt in the data model and print "Loading" in the cell and return the data later, I dont wanna to execute the query in the UI Thread. Any ideas to de that? Thanks

使用工作线程

  • Runnable#Thread,输出到 XxxTableModel 必须包装到 invokeLater

  • SwingWorker,方法 publish(同步)、process(同步)、done 的输出(异步)在 EDT 完成

关于java - 在 getValueAt 上执行查询并异步返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16982385/

相关文章:

java - 如何将 Eclipse 默认项目更改为 Java 项目

java - 如何使用 Spring 的 RestTemplate 来 POST 一个字符串数组

java - LibGDX 中的 JFileChooser

c# - AsyncTaskMethodBuilder AwaitUnsafeOnCompleted 与等待时的 AwaitOnCompleted

asynchronous - Flutter:如何在不阻塞 UI 的情况下异步地从 Assets 中读取文件

Java CompletableFuture : only first result

java - 如何检查 DirectedSparsedGraph 是否包含具有这 2 个节点的节点之间的边?

java - 在java中通过套接字连续流式传输数据

java - 隐藏 JSplitPane 的左/右组件(或不同的布局)

java - JTextPane 中的复制粘贴图标