I am stuck with a compilation error in Swing Worker?

瘦欲@ 提交于 2019-12-12 03:43:56

问题


I wrote a class that extends SwingWorker. I wrote overriden functions: doInBackground, done, and process, but for some reason I am getting compilation error:

The method process(List) of type BillImportAnalyzerGUI.Task must override or implement a supertype method

Here is my class:

  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);
    }
  }

回答1:


The problem is that you're extending SwingWorker<Void,Void> but you're declaring the method as process(List<String> chunks).

You should extend SwingWorker<Void,String> in this case.



来源:https://stackoverflow.com/questions/15245505/i-am-stuck-with-a-compilation-error-in-swing-worker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!