javafx.concurrent.Worker.getState()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(273)

本文整理了Java中javafx.concurrent.Worker.getState()方法的一些代码示例,展示了Worker.getState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Worker.getState()方法的具体详情如下:
包路径:javafx.concurrent.Worker
类名称:Worker
方法名:getState

Worker.getState介绍

暂无

代码示例

代码示例来源:origin: org.controlsfx/controlsfx

public final void setWorker(final Worker<?> newWorker) { 
  if (newWorker != worker) {
    if (worker != null) {
      worker.stateProperty().removeListener(stateListener);
      end();
    }
    worker = newWorker;
    if (newWorker != null) {
      newWorker.stateProperty().addListener(stateListener);
      if (newWorker.getState() == Worker.State.RUNNING || newWorker.getState() == Worker.State.SCHEDULED) {
        // It is already running
        begin();
      }
    }
  }
}

代码示例来源:origin: io.datafx/core

public static ReadOnlyBooleanProperty createIsDoneProperty(Worker<?> worker) {
    final BooleanProperty property = new SimpleBooleanProperty();
    Consumer<Worker.State> stateChecker = (s) -> {
      if (s.equals(Worker.State.CANCELLED) || s.equals(Worker.State.FAILED) || s.equals(Worker.State.SUCCEEDED)) {
        property.setValue(true);
      } else {
        property.setValue(false);
      }
    };
    worker.stateProperty().addListener((o, oldValue, newValue) -> stateChecker.accept(newValue));
    stateChecker.accept(worker.getState());
    return property;

  }
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

private void createScene(final String htmlContent) {
  Platform.setImplicitExit(false);
  Platform.runLater(() -> {
      WebView view = new WebView();
      engine = view.getEngine();
      engine.setOnStatusChanged(event -> SwingUtilities.invokeLater(() -> lblStatus.setText(event.getData())));
      engine.getLoadWorker().workDoneProperty()
          .addListener((ChangeListener<Number>) (observableValue, oldValue, newValue) -> SwingUtilities
              .invokeLater(() -> progressBar.setValue(newValue.intValue())));
      engine.getLoadWorker().exceptionProperty()
          .addListener((ObservableValue<? extends Throwable> o,
              Throwable old, final Throwable value) -> {
              if (engine.getLoadWorker().getState() == State.FAILED) {
                SwingUtilities.invokeLater(() -> JOptionPane
                    .showMessageDialog(
                        resultsScrollPane,
                        (value != null) ? engine
                            .getLocation()
                            + "\n"
                            + value.getMessage()
                            : engine.getLocation()
                                + "\nUnexpected error.",
                        "Loading error...",
                        JOptionPane.ERROR_MESSAGE));
              }
          });
      jfxPanel.setScene(new Scene(view));
  });
}

代码示例来源:origin: stackoverflow.com

Worker worker = webEngine.getLoadWorker();
worker.stateProperty().addListener((Observable o) -> {
  if (worker.getState() == Worker.State.SUCCEEDED) {
    EventQueue.invokeLater(() -> {
      table.setModel(new AbstractTableModel() {

代码示例来源:origin: org.controlsfx/controlsfx

public ProgressDialog(final Worker<?> worker) {
  if (worker != null
      && (worker.getState() == State.CANCELLED
      || worker.getState() == State.FAILED
      || worker.getState() == State.SUCCEEDED)) {
    return;

相关文章