【问题标题】:I am stuck with a compilation error in Swing Worker?我在 Swing Worker 中遇到编译错误?
【发布时间】:2013-03-06 10:59:30
【问题描述】:

我写了一个扩展 SwingWorker 的类。我编写了覆盖函数:doInBackground、done 和 process,但由于某种原因我收到编译错误:

BillImportAnalyzerGUI.Task 类型的方法 process(List) 必须重写或实现超类型方法

这是我的课:

  private class Task extends SwingWorker<Void, Void>
  {
    @Override
    public Void doInBackground()
    {
      try
      {
        generateReport(BillImportId.getText());
      }
      catch (InterruptedException e)
      {
      }
      catch (Exception e)
      {
      }

      publish();

      return null;
    }

    @Override
    protected void done()
    {
      try
      {
        jLabel6.setText("Generated Report");
      }
      catch (Exception ignore)
      {
      }
    }

    @Override
    protected void process(List<String> chunks)
    {
      jLabel6.setText("Generating Report");
      jProgressBar1.setVisible(true);
    }
  }

【问题讨论】:

    标签: java swing swingworker


    【解决方案1】:

    问题是您正在扩展SwingWorker&lt;Void,Void&gt;,但您将方法声明为process(List&lt;String&gt; chunks)

    在这种情况下,您应该扩展 SwingWorker&lt;Void,String&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-10
      • 1970-01-01
      • 1970-01-01
      • 2019-07-26
      相关资源
      最近更新 更多