Advertisement
Guest User

help

a guest
Jan 12th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import java.util.Random;
  5.  
  6. // Class definition
  7. public class TEMPLATE extends JPanel implements ActionListener {
  8. private Font newFont = new Font("sansserif", Font.BOLD, 20);
  9. private Graphics bufferGraphics;
  10. private Image offscreen;
  11. public static final int
  12. WIDTH = 800,
  13. HEIGHT = 600;
  14.  
  15. private boolean gameOver = false;
  16. private Timer time = new Timer(15, this);
  17. private Random rgen = new Random();
  18.  
  19. // Constructor method declaration
  20. public TEMPLATE() {
  21. setBackground(Color.black);
  22.  
  23. offscreen = createImage(WIDTH, HEIGHT);
  24. bufferGraphics = offscreen.getGraphics();
  25.  
  26. setFocusable(true);
  27. requestFocus();
  28.  
  29. makeFrame();
  30. }
  31.  
  32. //Other Stuff...
  33.  
  34. public void makeFrame() {
  35.  
  36. // Instantiate a window frame using Swing class JFrame
  37. JFrame frame = new JFrame("TEMPLATE");
  38.  
  39. // When the window is closed terminate the application
  40. frame.addWindowListener(new WindowAdapter() {
  41. public void windowClosing(WindowEvent e) {
  42. System.exit(0);
  43. }
  44. });
  45.  
  46. // set initial size of window
  47. frame.setSize(WIDTH, HEIGHT);
  48.  
  49. // add the current object to the centre of the frame and make visible
  50. frame.getContentPane().add(this, BorderLayout.CENTER);
  51. frame.setVisible(true);
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement