public void openCaptureWindow() {
    if (framenr - lastcapture_framenr < number_of_frames_before_cwopen) {
      return;
    }

    // Capture Window
    cw.setVisible(true);
    cw.toFront();

    // Timer for closing the capturewindow
    TimerTask task =
        new TimerTask() {

          @Override
          public void run() {
            EventQueue.invokeLater(
                new Runnable() {
                  public void run() {
                    System.out.println("Closing cw...");
                    cw.setVisible(false);
                    cwText.setText(""); // Empty text in case there is a text
                  }
                });
          }
        };
    cwTimer = new Timer();
    cwTimer.schedule(task, number_of_second_capturewindow * 1000);
  }