# fullscreen



## coolerouny (20. Mai 2005)

morgen!

ich wollte euch fragen ob ihr wisst wie man in java eine fullscreen anwendung machen kann,
bei der man auch die auflösung ändern kann

mfg
coolerouny


----------



## Thomas Darimont (21. Mai 2005)

Hallo!

Schau mal hier:

```
/**
 * 
 */
package de.tutorials;

import java.awt.Cursor;
import java.awt.DisplayMode;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

/**
 * @author Tom
 * 
 */
public class FullScreenExample extends JFrame {

	BufferStrategy strategy;

	Point mouseLocation;

	Thread runner = new Thread() {
		public void run() {
			BufferedImage img = null;

			try {
				img = ImageIO.read(new File("c:/pac.png"));
			} catch (IOException e) {
				e.printStackTrace();
			}

			if (img == null)
				return;

			while (true) {
				if (mouseLocation != null && FullScreenExample.this.isVisible()) {
					Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
					g.clearRect(0, 0, 800, 600);
					g.drawImage(img, mouseLocation.x, mouseLocation.y, null);
					g.dispose();
					strategy.show();
				}
				try {
					sleep(50L);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}

		}
	};

	public FullScreenExample() {

		setUndecorated(true);

		GraphicsDevice device = GraphicsEnvironment
				.getLocalGraphicsEnvironment().getDefaultScreenDevice();

		setSize(800, 600);

		device.setFullScreenWindow(this);
		device.setDisplayMode(new DisplayMode(800, 600, 16, 85));

		addKeyListener(new KeyAdapter() {
			public void keyPressed(KeyEvent e) {
				if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
					setVisible(false);
					dispose();
					System.exit(0);
				}
			}
		});

		addMouseMotionListener(new MouseMotionAdapter() {
			public void mouseDragged(MouseEvent e) {
				mouseLocation = e.getPoint();
			}
		});

		setVisible(true);
		createBufferStrategy(2);
		strategy = getBufferStrategy();

		// disable local pointer
		BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
		Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(img,
				new Point(1, 1), "");
		setCursor(cur);

		runner.start();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new FullScreenExample();
	}

}
```

Gruß Tom


----------



## Billie (21. Mai 2005)

http://java.sun.com/docs/books/tutorial/extra/fullscreen/


----------



## coolerouny (23. Mai 2005)

super danke!

mfg
coolerouny


----------



## keimax (20. August 2007)

Hmm diei Geschwindigkeit bei grossen Bildern ist ziemlich eingeschränkt, kann man da noch was rausholen?
Danke


----------



## zerix (20. August 2007)

Hallo,

meinst du bei Toms Beispiel?

MFG

zEriX


----------

