Example #1
0
  public void run() {

    while (true) {
      int event = getEvent();

      if (event == 2) return;
      // Thread should stop

      if (event == 0) {
        screen.drawToComponent(backbuffer.getGraphics());

        synchronized (this) {
          Image temp = frontbuffer;
          frontbuffer = backbuffer;
          backbuffer = temp;
          frontbufferValid = true;
          state = 1;
          this.notifyAll();
        }
      } else if (event == 3) {
        DasherTasklet toRun = events.remove();
        toRun.run();
      }
    }
  }
Example #2
0
  public synchronized void setSize(int width, int height) {

    if (this.width == width && this.height == height) {
      return;
    } else {
      frontbufferValid = false;
      state = 0;
      backbuffer = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
      frontbuffer = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
      this.width = width;
      this.height = height;
      screen.setSize(width, height);
      this.notifyAll();
    }
  }