Camtech075

ASDF

Oct 15th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. package graphics.main;
  2.  
  3. import javax.swing.JFrame;
  4. import java.awt.Container;
  5. import java.awt.event.KeyListener;
  6. import java.awt.event.ActionListener;
  7. import javax.swing.JPanel;
  8. import javax.swing.BoxLayout;
  9. import javax.swing.JLabel;
  10. import javax.swing.WindowConstants;
  11. import java.awt.Point;
  12. import java.awt.Dimension;
  13. import java.awt.Graphics;
  14. import java.awt.Color;
  15. import java.awt.FlowLayout;
  16. import engine.FireEmblemEngine;
  17. import engine.system.*;
  18. import graphics.img.fireemblem.*;
  19.  
  20. /**
  21. * This class displays the basic game frame.
  22. */
  23.  
  24. public class GameFrame extends JPanel implements GameConstants,FEImages {
  25.  
  26. protected static final int GAME_WIDTH = 600;
  27. protected static final int GAME_HEIGHT = 400;
  28.  
  29. //JFrame gFrame;
  30. JLabel label;
  31. protected static JFrame gFrame;
  32.  
  33. private static final Dimension preferredSize = new Dimension(GAME_WIDTH,GAME_HEIGHT);
  34.  
  35. //Finds the size of the frame.
  36.  
  37. public Dimension getPreferredSize() {
  38.  
  39. return preferredSize;
  40.  
  41. }
  42.  
  43. //Whee, constructor.
  44.  
  45. public GameFrame(JFrame j) {
  46.  
  47. FireEmblemEngine gameEngine = new FireEmblemEngine(this);
  48. j.addKeyListener(gameEngine);
  49.  
  50. }
  51.  
  52. public JFrame getFrame() {
  53.  
  54. if (gFrame != null)
  55. {
  56.  
  57. return gFrame;
  58.  
  59. }
  60. else
  61. {
  62.  
  63. return null;
  64.  
  65. }
  66.  
  67. }
  68.  
  69. public void addPanelToFrame(Container c) {
  70.  
  71. c.add(this);
  72.  
  73. }
  74.  
  75. public void paintComponent(Graphics g) {
  76.  
  77. super.paintComponent(g);
  78.  
  79. //Fill the entire screen with white
  80. g.setColor(Color.WHITE);
  81. g.fillRect(0,0,GAME_WIDTH,GAME_HEIGHT);
  82. //Container conPane = gFrame.getContentPane();
  83.  
  84. }
  85.  
  86. //Actually display the frame
  87. public static void main(String[] args) {
  88.  
  89. gFrame = new JFrame("Fire Emblem!");
  90.  
  91. GameFrame game = new GameFrame(gFrame);
  92.  
  93. Container contentPane = gFrame.getContentPane();
  94.  
  95. game.addPanelToFrame(contentPane);
  96. contentPane.setLayout(new FlowLayout());
  97.  
  98. //label.setIcon(FELogo);
  99.  
  100. //JLabel label = new JLabel(FELogo);
  101. //contentPane.add(label);
  102.  
  103. gFrame.pack();
  104. //gFrame.setSize(preferredSize);
  105. gFrame.setResizable(false);
  106. gFrame.setVisible(true);
  107. gFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  108.  
  109. }
  110.  
  111. }
  112.  
  113.  
  114.  
Advertisement
Add Comment
Please, Sign In to add comment