org.teavm.jso.browser.Window.setTimeout()方法的使用及代码示例

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

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

Window.setTimeout介绍

暂无

代码示例

代码示例来源:origin: konsoletyper/teavm

@Override public void onTimer() {
    new Thread(() -> {
      if (cancelled || task.timer == null) {
        return;
      }
      task.nativeTimerId = Window.setTimeout(this, (int) period);
      TTimerTask.performOnce(task);
      if (!cancelled) {
        task.timer = TTimer.this;
      }
    }).start();
  }
};

代码示例来源:origin: konsoletyper/teavm

@Override public void onTimer() {
    new Thread(() -> {
      if (cancelled || task.timer == null) {
        return;
      }
      long nextDelay = nextStartTime[0] - System.currentTimeMillis();
      if (nextDelay < 0) {
        nextDelay = 0;
      }
      task.nativeTimerId = Window.setTimeout(this, (int) nextDelay);
      nextStartTime[0] += period;
      TTimerTask.performOnce(task);
      if (!cancelled) {
        task.timer = TTimer.this;
      }
    }).start();
  }
};

代码示例来源:origin: konsoletyper/teavm

public void schedule(final TTimerTask task, long delay, final long period) {
  if (cancelled || task.timer != null || task.nativeTimerId >= 0) {
    throw new TIllegalStateException();
  }
  task.timer = this;
  TimerHandler handler = new TimerHandler() {
    @Override public void onTimer() {
      new Thread(() -> {
        if (cancelled || task.timer == null) {
          return;
        }
        task.nativeTimerId = Window.setTimeout(this, (int) period);
        TTimerTask.performOnce(task);
        if (!cancelled) {
          task.timer = TTimer.this;
        }
      }).start();
    }
  };
  task.nativeTimerId = Window.setTimeout(handler, (int) delay);
}

代码示例来源:origin: konsoletyper/teavm

public void schedule(final TTimerTask task, long delay) {
  if (cancelled || task.timer != null || task.nativeTimerId >= 0) {
    throw new TIllegalStateException();
  }
  task.timer = this;
  task.nativeTimerId = Window.setTimeout(() -> {
    new Thread(() -> {
      if (cancelled || task.timer == null) {
        return;
      }
      TTimerTask.performOnce(task);
    }).start();
  }, (int) delay);
}

代码示例来源:origin: konsoletyper/teavm

public void scheduleAtFixedRate(final TTimerTask task, long delay, long period) {
    if (cancelled || task.timer != null || task.nativeTimerId >= 0) {
      throw new TIllegalStateException();
    }
    final long[] nextStartTime = new long[]{System.currentTimeMillis() + delay};
    task.timer = this;
    TimerHandler handler = new TimerHandler() {
      @Override public void onTimer() {
        new Thread(() -> {
          if (cancelled || task.timer == null) {
            return;
          }
          long nextDelay = nextStartTime[0] - System.currentTimeMillis();
          if (nextDelay < 0) {
            nextDelay = 0;
          }
          task.nativeTimerId = Window.setTimeout(this, (int) nextDelay);
          nextStartTime[0] += period;
          TTimerTask.performOnce(task);
          if (!cancelled) {
            task.timer = TTimer.this;
          }
        }).start();
      }
    };
    task.nativeTimerId = Window.setTimeout(handler, (int) delay);
    nextStartTime[0] += period;
  }
}

代码示例来源:origin: konsoletyper/teavm-libgdx

private void delayedStep() {
  window.setTimeout(() -> step(), 10);
}

代码示例来源:origin: konsoletyper/teavm-flavour

public void dropDown() {
  if (dropDownElement != null) {
    return;
  }
  dropDownElement = HTMLDocument.current().createElement("div");
  dropDownElement.setAttribute("class", "flavour-dropdown flavour-dropdown-calendar");
  TextRectangle windowRect = HTMLDocument.current().getBody().getBoundingClientRect();
  TextRectangle inputRect = target.getElement().getBoundingClientRect();
  dropDownElement.getStyle().setProperty("right", windowRect.getWidth() - inputRect.getRight() + "px");
  dropDownElement.getStyle().setProperty("top", inputRect.getBottom() + "px");
  CalendarDropDown dropDown = new CalendarDropDown(this::parseValue, newValue -> {
    closeDropDown();
    target.updateValue(cachedFormatObject.format(newValue));
  });
  dropDownComponent = Templates.bind(dropDown, dropDownElement);
  HTMLDocument.current().getBody().appendChild(dropDownElement);
  Window.setTimeout(() -> HTMLDocument.current().addEventListener("click", bodyListener), 0);
}

相关文章