weird. I’ve tried it on 3 Windows machines with different video card manufacturers, about 4 linux machines, and 1 Mac Powerbook, with none of those problems. Here’s my code that SHOULD pop up the game frame that doesn’t seem to be working for you guys:
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
oldDisplayMode = device.getDisplayMode();
Canvas canvas = new Canvas();
frame = new Frame(device.getDefaultConfiguration());
frame.addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
visible = true;
}
public void windowDeactivated(WindowEvent e) {
visible = false;
}
public void windowClosing(WindowEvent e) {
running = false;
dispose();
System.exit(0);
}
});
frame.setIgnoreRepaint(true);
frame.setResizable(false);
boolean frameIsControlling = true;
DisplayMode[] options = device.getDisplayModes();
DisplayMode chosenDisplayMode = null;
for (int i = 0; i < options.length; i++) {
if (options[i].getWidth() == resolution.getWidth()
&& options[i].getHeight() == resolution.getHeight()
&& options[i].getBitDepth() == colorDepth) {
chosenDisplayMode = options[i];
break;
}
}
// If full screen is wanted (and possible), set it up.
if (fullscreen) {// && chosenDisplayMode != null) {
this.fullscreen = fullscreen;
GAME_WIDTH = (int)resolution.getWidth();
GAME_HEIGHT = (int)resolution.getHeight();
if (chosenDisplayMode == null || !device.isFullScreenSupported()) {
if (chosenDisplayMode == null)
System.out.println("display mode not found");
else
System.out.println("display mode found");
System.out.println("device.isFullScreenSupported() is " + device.isFullScreenSupported());
//if we can't go full screen but we're using the current resolution, we have to
//adjust to make sure we don't draw under the start menu bar
if (resolution.getWidth() == oldDisplayMode.getWidth() && resolution.getHeight() == oldDisplayMode.getHeight()) {
setFullSizedWindow(canvas);
}
else {
GAME_WIDTH = (int)resolution.getWidth();
GAME_HEIGHT = (int)resolution.getHeight();
canvas.setSize(GAME_WIDTH, GAME_HEIGHT);
frame.add(canvas);
frame.pack();
Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
frame.setLocation(centerPoint.x - frame.getWidth()/2, centerPoint.y - frame.getHeight()/2);
}
frameIsControlling = false;
}
else {
frame.setLayout(null);
frame.setUndecorated( true ); // No window decorations
device.setFullScreenWindow( frame ); // Create a full screen window
if (!chosenDisplayMode.equals(oldDisplayMode))
device.setDisplayMode( chosenDisplayMode ); // Change to our preferred mode
}
}
// Otherwise we use a window with a fixed size
else {
if (resolution.getWidth() == oldDisplayMode.getWidth() && resolution.getHeight() == oldDisplayMode.getHeight()) {
setFullSizedWindow(canvas);
}
else {
GAME_WIDTH = (int)resolution.getWidth();
GAME_HEIGHT = (int)resolution.getHeight();
canvas.setSize(GAME_WIDTH, GAME_HEIGHT);
frame.add(canvas);
frame.pack();
Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
frame.setLocation(centerPoint.x - frame.getWidth()/2, centerPoint.y - frame.getHeight()/2);
}
frameIsControlling = false;
}
frame.show();
frame.setIconImage(PreLoader.icon);
if (frameIsControlling) {
frame.createBufferStrategy( 2 );
strategy = frame.getBufferStrategy();
frame.addKeyListener(this);
frame.addMouseListener(this);
frame.addMouseMotionListener(this);
}
else {
canvas.createBufferStrategy( 2 );
strategy = canvas.getBufferStrategy();
canvas.addKeyListener(this);
canvas.addMouseListener(this);
canvas.addMouseMotionListener(this);
}
frame.setTitle("Rimscape");
Is there anything wrong with what I’m doing? Hopefully there is and you guys can point it out so I can fix it Thanks!
Edited the code!!