Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainMenu extends JFrame {
- private JPanel contentPane;
- /**
- * Launch the application.
- */
- //variables
- public static Image bg;
- public static void main(String[] args) {
- MainMenu mainFrame = new MainMenu();
- mainFrame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
- mainFrame.setResizable(false);
- mainFrame.setLocationRelativeTo(null);
- mainFrame.setTitle ("Zumby");
- mainFrame.setLayout(null);
- // Loads the background image and stores in bg object.
- try {
- bg = ImageIO.read(new File("zumby.png"));
- } catch (IOException e) {
- }
- mainFrame.setVisible(true);
- }
- /**
- * Overrides the paint method.
- * MONDAY
- */
- public void paint(Graphics g)
- {
- // Draws the img to the BackgroundPanel.
- System.out.println("paint");
- g.drawImage(bg, 0, 0, null);
- }
- /**
- */
- public MainMenu() {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 800, 500);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- contentPane.setOpaque(false);
- setContentPane(contentPane);
- contentPane.setLayout(null);
- //create buttons
- JButton btnPlay = new JButton("PLAY");
- btnPlay.setBackground(Color.BLACK);
- btnPlay.setForeground(Color.WHITE);
- btnPlay.setFont(font);
- btnPlay.setBorder(border);
- btnPlay.setFocusPainted(false);
- //if "Play" is clicked
- btnPlay.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent click) {
- setVisible(false);
- new GamePlay(); //opens up GamePlay window
- }
- });
- btnPlay.setBounds(600, 64, 141, 61);
- contentPane.add(btnPlay);
- JButton btnInstructions = new JButton("INSTRUCTIONS");
- btnInstructions.setBounds(600, 160, 141, 61);
- btnInstructions.setBackground(Color.BLACK);
- btnInstructions.setFocusPainted(false);
- // btnInstructions.setEnabled(true);
- contentPane.add(btnInstructions);
- repaint();
- pack();
- setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement