From 3a4deb5e85844c5862af1fb8afebcacc61e8bfe7 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sun, 15 Feb 2009 15:13:03 -0500 Subject: Engine: Hid PuzzleApplication's gameFrame --- src/com/fourisland/fourpuzzle/Display.java | 8 ++++---- .../fourisland/fourpuzzle/PuzzleApplication.java | 24 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/com/fourisland/fourpuzzle/Display.java b/src/com/fourisland/fourpuzzle/Display.java index de72c4d..686bd8e 100755 --- a/src/com/fourisland/fourpuzzle/Display.java +++ b/src/com/fourisland/fourpuzzle/Display.java @@ -12,6 +12,7 @@ import com.fourisland.fourpuzzle.transition.Transition; import com.fourisland.fourpuzzle.transition.TransitionDirection; import com.fourisland.fourpuzzle.transition.TransitionUnsupportedException; import com.fourisland.fourpuzzle.util.Renderable; +import java.awt.Component; import java.awt.Font; import java.awt.FontFormatException; import java.awt.FontMetrics; @@ -27,7 +28,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.JDialog; import org.jdesktop.application.ResourceMap; /** @@ -40,7 +40,7 @@ public class Display { private static List renderables = new CopyOnWriteArrayList(); - public static void render(JDialog gameFrame) + public static void render(Component gameFrame) { VolatileImage vImg = gameFrame.createVolatileImage(Game.WIDTH, Game.HEIGHT); render(gameFrame, vImg); @@ -61,7 +61,7 @@ public class Display { img = vImg; } while (vImg.contentsLost()); - gameFrame.getContentPane().getGraphics().drawImage(img, 0, 0, gameFrame.getContentPane().getWidth(), gameFrame.getContentPane().getHeight(), gameFrame); + gameFrame.getGraphics().drawImage(img, 0, 0, gameFrame.getWidth(), gameFrame.getHeight(), gameFrame); img.flush(); Toolkit.getDefaultToolkit().sync(); @@ -73,7 +73,7 @@ public class Display { } } - private static void render(JDialog gameFrame, VolatileImage vImg) + private static void render(Component gameFrame, VolatileImage vImg) { if (vImg.validate(gameFrame.getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE) { diff --git a/src/com/fourisland/fourpuzzle/PuzzleApplication.java b/src/com/fourisland/fourpuzzle/PuzzleApplication.java index 069b126..f5c461e 100755 --- a/src/com/fourisland/fourpuzzle/PuzzleApplication.java +++ b/src/com/fourisland/fourpuzzle/PuzzleApplication.java @@ -9,6 +9,7 @@ import com.fourisland.fourpuzzle.database.Vocabulary; import com.fourisland.fourpuzzle.gamestate.TitleScreenGameState; import com.fourisland.fourpuzzle.util.Interval; import com.fourisland.fourpuzzle.window.SystemGraphic; +import java.awt.Frame; import java.awt.GraphicsEnvironment; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; @@ -26,7 +27,6 @@ import org.jdesktop.application.Application; public class PuzzleApplication extends Application { public static PuzzleApplication INSTANCE; - public static JDialog gameFrame; public static boolean debugSpeed = false; public static boolean stretchScreen = true; public static boolean gameSleep = false; @@ -42,11 +42,11 @@ public class PuzzleApplication extends Application { protected void startup() { INSTANCE = this; - gameFrame = new JDialog(new JFrame(), false); - gameFrame.setTitle(Database.getVocab(Vocabulary.Title)); - gameFrame.setSize(Game.WIDTH * 2, Game.HEIGHT * 2); - gameFrame.setResizable(false); - gameFrame.addWindowListener(new WindowAdapter() { + final JDialog gameDialog = new JDialog(new JFrame(), false); + gameDialog.setTitle(Database.getVocab(Vocabulary.Title)); + gameDialog.setSize(Game.WIDTH * 2, Game.HEIGHT * 2); + gameDialog.setResizable(false); + gameDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); @@ -62,22 +62,22 @@ public class PuzzleApplication extends Application { gameSleep = true; } }); - gameFrame.addKeyListener(new KeyAdapter() { + gameDialog.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F4) { - GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(gameFrame); + GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(gameDialog); } else if (e.getKeyCode() == KeyEvent.VK_F5) { stretchScreen = !stretchScreen; if (stretchScreen) { - gameFrame.setSize(Game.WIDTH * 2, Game.HEIGHT * 2); + gameDialog.setSize(Game.WIDTH * 2, Game.HEIGHT * 2); } else { - gameFrame.setSize(Game.WIDTH, Game.HEIGHT); + gameDialog.setSize(Game.WIDTH, Game.HEIGHT); } } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) { @@ -101,7 +101,7 @@ public class PuzzleApplication extends Application { } } }); - gameFrame.setVisible(true); + gameDialog.setVisible(true); new Thread(new Runnable() { public void run() { @@ -123,7 +123,7 @@ public class PuzzleApplication extends Application { Game.getGameState().doGameCycle(); } - Display.render(gameFrame); + Display.render(gameDialog.getContentPane()); } } } catch (RuntimeException ex) { -- cgit 1.4.1