Simple Fullscreen

Hi
I do not understand the Java Fullscreen Tutorial …
http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html

I want to create a simple program with Swing which creates a black Screen where a text says
“Exit with Escape”
and escape ends it …

I can do this in a JFrame Window but with Fullscreen I do not know … please help!!

This should get you started.


import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferStrategy;

import javax.swing.JFrame;

public class Test extends JFrame implements KeyListener, Runnable {
    private boolean running;
    private boolean keys[];
    
    public Test() {
        setSize(100, 100);
        setVisible(true);
        running = true;
        addKeyListener(this);
        keys = new boolean[65536];
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public void run() {
        GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        try {
            setIgnoreRepaint(true);
            DisplayMode displayMode = device.getDisplayMode();
            device.setFullScreenWindow(this);
            createBufferStrategy(2);
            BufferStrategy strategy = getBufferStrategy();
            while(running) {
                Graphics g = strategy.getDrawGraphics();
                g.setColor(Color.BLACK);
                g.fillRect(0, 0, displayMode.getWidth(), displayMode.getHeight());
                g.setColor(Color.WHITE);
                g.drawString("Press ESCAPE to exit", 350, 300);
                g.dispose();
                strategy.show();
                if(keys[KeyEvent.VK_ESCAPE]) {
                    running = false;
                }
                Thread.sleep(50);
            }
        }
        catch(Exception e) {
            e.printStackTrace();
        }
        finally {
            device.setFullScreenWindow(null);
        }
        setVisible(false);
        System.exit(0);
    }
    public void keyPressed(KeyEvent e) {
        keys[e.getKeyCode()] = true;
    }

    public void keyReleased(KeyEvent e) {
        keys[e.getKeyCode()] = false;
    }

    public void keyTyped(KeyEvent e) {
    }
    public static void main(String[] argv) {
        Test t = new Test();
        Thread th = new Thread(t);
        th.start();
    }
}