Hello,

Stupid question time. :-)

Why does the following code (correctly) display a black screen with white 
numbers under Linux, but just grey under Windows XP? Tested on Java 1.4 and 5 
under Windows, Java 1.4, 5, and 6 under Linux (it even works in Kaffe!).

I know I'm missing something obvious. :-P

Thanks!

William

[pre]import java.awt.*;
import java.awt.image.*;
import javax.swing.*;

public class BufferTest {
  public static void main(String args[]) {
    JFrame frame;
    Canvas canvas;
    GraphicsDevice device;
    BufferStrategy strategy;
    DisplayMode mode;

    canvas = new Canvas();
    frame = new JFrame();
    frame.setUndecorated(true);

    canvas.setIgnoreRepaint(true);

    device = 
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    mode = device.getDisplayMode();

    frame.setSize(mode.getWidth(), mode.getHeight());
    frame.getContentPane().add(canvas);
    device.setFullScreenWindow(frame);
    frame.show();

    try {
      canvas.createBufferStrategy(2);
      strategy = canvas.getBufferStrategy();

      for (int counter = 100; counter >= 0; --counter) {
        Graphics g = strategy.getDrawGraphics();
        g.setColor(Color.BLACK);
        g.fillRect(0, 0, mode.getWidth(), mode.getHeight());
        g.setColor(Color.WHITE);
        g.drawString(Integer.toString(counter), mode.getWidth() / 2, 
mode.getHeight() / 2);
        g.dispose();
        strategy.show();
        Toolkit.getDefaultToolkit().beep();
        Thread.sleep(100);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      device.setFullScreenWindow(null);
      System.exit(0);
    }
  }
}
[/pre]
[Message sent by forum member 'afishionado' (afishionado)]

http://forums.java.net/jive/thread.jspa?messageID=136491

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to