我的项目遵循以下流程:
我想使用 swingworker。这是我使用它的方式,但结果不正确
在我的 GUI 代码中,我的代码是用于执行主体类的
我在按钮代码中编写了以下代码行
Main f2 = new Main();
f2.execute();
在我的校长课上,我已经这样做了
class Principalclass extends SwingWorker<Void, Void>
{
@Override
public Void doInBackground() throws IOException
{
//while loop
}
@Override
public void done() {
System.out.println("I am DONE");
GUI b = new GUI();
b.ShowFrame(); //calls the function of the GUI to display frame
}
现在这段代码没有打印“我完成了”显示了 GUI 框架。如果我必须在使用 swingworker 的 2,3 和 4 类 bcz 中进行一些更改,或者我必须仅在 Principalclass.Secondly 中进行进一步更改,我会感到困惑,该应用程序需要 15 分钟才能完成其任务,只需要 2 秒 :(。可能是我做错了什么,因为我是第一次使用 Swing Worker。