java - 在 actionperformed 中创建 JDialog
问题描述
我正在开发一个用于读取 JSON 文件然后将其写入文件的 swing 应用程序。操作项将列在显示文件元数据的 JTable 行中,每行的最后一列都有一个按钮,用于将 JSON 打印到本地文件中。
在执行的操作中,我计划显示一个自定义 JDialog 以防止 UI 中的任何操作,这会阻止所有进一步的步骤,例如写入文件。
这是否可以在显示 JDialog 后启动一个线程来调用文件重新操作的函数?我使用 Thread 尝试过这种方式,但这也被阻止了。
@Override
public void actionPerformed(ActionEvent e) {
JButton printerButton = (JButton) e.getSource();
String ac = printerButton.getActionCommand();
System.out.println("ac = " + ac);
/*
* **Start JDialog for blocking any operation on the window**
*/
/*
* **Start a thread for writing a file**
*/
}
解决方案
推荐阅读
- javascript - 我无法在 html 中打印 js 变量
- dart - 如何使用 dart 设计这样的用户中心 ui
- wpf - 为什么 WPF PathFigure 在某些旋转时未填充?
- excel - 根据另一个工作表中单元格中的值合并特定数量的单元格
- compilation - qemu 无法引导内核版本 2.6.34.7
- excel - VBA 按钮可深入到数据透视表
- javascript - 反应变量值更改不更新反应组件
- r - 从转移矩阵创建马尔可夫链对象
- javascript - 如何在 Array 对象中重复更改值
- apostrophe-cms - 如何从控制器渲染 nunjucks 模板