...

View Full Version : Full Screen Not Working



javarower
02-27-2012, 08:37 PM
I am making a full screen gui and then putting a picture on it. I can get the picture to display in windowed mode however whenever i display it in full screen it does not work.
Here is the code I use for making it full screen:
[CODE]
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
gd.setFullScreenWindow( frame );
if( gd.isDisplayChangeSupported() ) {
gd.setDisplayMode(
new DisplayMode( 640, 480, 32, DisplayMode.REFRESH_RATE_UNKNOWN )
);
} [CODE]



Here is my full code:

[CODE]
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ImageProducer;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.*;

public class **** extends Canvas{
Image image;

public ****() {
MediaTracker media = new MediaTracker(this);
image = Toolkit.getDefaultToolkit().getImage("pokemon.png");
media.addImage(image, 0);
try {
media.waitForID(0);
}
catch (Exception e) {}
}

public ****(ImageProducer imageProducer){
image = createImage(imageProducer);
}

public void paint(Graphics g) {
g.drawImage(image, 0,0, this);
Graphics2D g2d = null;

}

public static void main(String args[]) {
Frame frame = new Frame();
frame.setLayout(new BorderLayout());
frame.add("Center", new ****());
frame.resize(400,400);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
gd.setFullScreenWindow( frame );
if( gd.isDisplayChangeSupported() ) {
gd.setDisplayMode(
new DisplayMode( 640, 480, 32, DisplayMode.REFRESH_RATE_UNKNOWN )
);
}
frame.show();
}
}
[CODE]

javarower
02-28-2012, 01:46 AM
Oh sry my class was named **** spelled 's' 'h' 'i' 't' and that is why the class names are **** and the constructor is ****() and it goes new ****().



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum