public void addClient() {
    client =
        new Canvas() {
          public void paint(Graphics g) {
            super.paint(g);
          }
        };
    client.setBackground(new Color(30, 220, 40));
    clientCont.add(client);
    clientCont.validate();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    WindowIDProvider pid = (WindowIDProvider) acc.getPeer(client);
    log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
    Rectangle toFocusBounds = toFocus.getBounds();
    toFocusBounds.setLocation(toFocus.getLocationOnScreen());
    f.validate();

    // KDE doesn't accept clicks on title as activation - click below title
    Rectangle fbounds = f.getBounds();
    fbounds.y += f.getInsets().top;
    fbounds.height -= f.getInsets().top;

    Process proc =
        startClient(
            new Rectangle[] {
              fbounds,
              dummy.getBounds(),
              toFocusBounds,
              new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
              new Rectangle(10, 130, 20, 20)
            },
            pid.getWindow());
    new ClientWatcher(client, proc, clientCont).start();
  }
  public void doit() throws Exception {

    Image image = (Image) this.pullInput(0);
    Rectangle bounds = mainFrame.getBounds();
    Graphics g = bufferStrategy.getDrawGraphics();
    if (!bufferStrategy.contentsLost()) {
      g.drawImage(image, 0, 0, null);
      // g.drawImage(image, 0, 0, bounds.width, bounds.height, null);
      // g.fillRect(0, 0, bounds.width, bounds.height);
      bufferStrategy.show();
      g.dispose();
    }
  }
Beispiel #3
0
 public MultiBufferTest(int numBuffers, GraphicsDevice device) {
   try {
     GraphicsConfiguration gc = device.getDefaultConfiguration();
     mainFrame = new Frame(gc);
     mainFrame.setUndecorated(true);
     mainFrame.setIgnoreRepaint(true);
     device.setFullScreenWindow(mainFrame);
     //            if (device.isDisplayChangeSupported()) {
     //                chooseBestDisplayMode(device);
     //            }
     Rectangle bounds = mainFrame.getBounds();
     mainFrame.createBufferStrategy(numBuffers);
     BufferStrategy bufferStrategy = mainFrame.getBufferStrategy();
     for (float lag = 2000.0f; lag > 0.00000006f; lag = lag / 1.33f) {
       System.out.println("lag = " + lag);
       for (int i = 0; i < numBuffers; i++) {
         Graphics g = bufferStrategy.getDrawGraphics();
         if (!bufferStrategy.contentsLost()) {
           g.setColor(COLORS[i]);
           //                        g.fillRect(0,0,bounds.width, bounds.height);
           g.fillRect(0, 0, 20, 20);
           bufferStrategy.show();
           g.dispose();
         }
         try {
           Thread.sleep((int) lag);
         } catch (InterruptedException e) {
         }
       }
     }
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   } finally {
     device.setFullScreenWindow(null);
   }
 }