Advertisement
Guest User

Untitled

a guest
May 29th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.swing.*;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.awt.event.WindowEvent;
  6. import javax.swing.ImageIcon;
  7.  
  8. /**
  9. *
  10. * @author Sunny en Dennis
  11. */
  12. public class CheesyBirds20StuckInAMazeEdition {
  13.  
  14. private JPanel PanelMenu, PanelMaze;
  15. private JButton buttonStart, buttonReset, buttonExit;
  16. private JLabel labelTitle;
  17. private JTextArea textArea;
  18.  
  19. /**
  20. * @param args the command line arguments
  21. */
  22. public static void main(String[] args) {
  23. final JFrame introFrame = new JFrame(); //nieuwe JFrame als introscherm
  24.  
  25. JPanel intro = new JPanel(); //de jpanel op de nieuwe jframe
  26. JButton startButton = new JButton("START GAME"); //startknop op de jpanel om het spel mee te starten
  27. Icon icon = new ImageIcon("C:\\Maze\\introscherm.png");
  28. JLabel introLabel = new JLabel("", icon, JLabel.CENTER);
  29.  
  30. introFrame.add(intro); //hier zetten we de intro JPanel in de JFrame
  31. intro.add(startButton); //hier zetten we de startknop in de JPanel
  32. intro.add(introLabel); //hier zetten we de JLabel met de achtergrond-plaatje op onze introscherm
  33. introFrame.setSize(717 , 660); //hier geven we de size van onze JFrame
  34. introFrame.setLocationRelativeTo(null); // hiermee zet je de introFrame JFrame naar een centerpositie van je beeldscherm
  35. introFrame.setVisible(true); //hier maken we de JFrame zichtbaar op beeld
  36.  
  37.  
  38. startButton.addActionListener(new ActionListener() { //hier wordt de code achtger de startknop uitgevoerd
  39. public void actionPerformed(ActionEvent e) {
  40. introFrame.dispatchEvent(new WindowEvent(introFrame, WindowEvent.WINDOW_CLOSING));
  41. startGame();
  42. }
  43. });
  44. }
  45.  
  46. public static void startGame() {
  47. JFrame f = new JFrame();
  48. //JPanel PanelMenu = new JPanel();
  49. JPanel PanelMaze = new JPanel();
  50.  
  51. //PanelMenu.setLayout(new FlowLayout (FlowLayout.CENTER,0,0));
  52. PanelMaze.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
  53.  
  54. JButton buttonStart = new JButton("Start");
  55. buttonStart.setFont(new Font("Dialog", Font.BOLD, 18));
  56. JButton buttonReset = new JButton("Reset");
  57. buttonReset.setFont(new Font("Dialog", Font.BOLD, 18));
  58. JButton buttonExit = new JButton("Exit");
  59. buttonExit.setFont(new Font("Dialog", Font.BOLD, 18));
  60.  
  61. //PanelMenu.add(buttonStart);
  62. //PanelMenu.add(buttonReset);
  63. //PanelMenu.add(buttonExit);
  64. //f.add(PanelMenu);
  65. f.add(PanelMaze);
  66.  
  67. f.setTitle("Cheesy Birds 2.0: \"Stuck in a Maze Edition.\"");
  68. f.setSize(550, 550);
  69. f.setLocationRelativeTo(null);
  70.  
  71. f.add(new LevelMaker());
  72. f.setLocationRelativeTo(null);
  73. f.setVisible(true);
  74.  
  75. f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement