Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import java.util.Random;
- // Class definition
- public class TEMPLATE extends JPanel implements ActionListener {
- private Font newFont = new Font("sansserif", Font.BOLD, 20);
- private Graphics bufferGraphics;
- private Image offscreen;
- public static final int
- WIDTH = 800,
- HEIGHT = 600;
- private boolean gameOver = false;
- private Timer time = new Timer(15, this);
- private Random rgen = new Random();
- // Constructor method declaration
- public TEMPLATE() {
- setBackground(Color.black);
- offscreen = createImage(WIDTH, HEIGHT);
- bufferGraphics = offscreen.getGraphics();
- setFocusable(true);
- requestFocus();
- makeFrame();
- }
- //Other Stuff...
- public void makeFrame() {
- // Instantiate a window frame using Swing class JFrame
- JFrame frame = new JFrame("TEMPLATE");
- // When the window is closed terminate the application
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- });
- // set initial size of window
- frame.setSize(WIDTH, HEIGHT);
- // add the current object to the centre of the frame and make visible
- frame.getContentPane().add(this, BorderLayout.CENTER);
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement