Advertisement
Guest User

Jax's crappy menu

a guest
Jul 3rd, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.03 KB | None | 0 0
  1. import java.awt.event.ActionEvent;
  2. import java.awt.event.ActionListener;
  3. import java.awt.Color;
  4. import java.awt.Dimension;
  5.  
  6. import java.awt.Font;
  7.  
  8. import javax.swing.SwingUtilities;
  9. import javax.swing.JButton;
  10. import javax.swing.JFrame;
  11. import javax.swing.JLabel;
  12. import javax.swing.JOptionPane;
  13. import javax.swing.JPanel;
  14. import javax.swing.JTextField;
  15.  
  16.  
  17. public class GameMainMenu extends JFrame implements ActionListener{
  18.  
  19.    
  20.     JButton play, difficulty, credits;
  21.    
  22.     GameMainMenu(String title){
  23.        
  24.         super(title);
  25.         this.setSize(2000,1000);
  26.         this.init();
  27.         this.setVisible(true);
  28.         }
  29.    
  30.     void init(){
  31.        
  32.         JFrame f = new JFrame();
  33.        
  34.         JLabel lmainMenu = new JLabel("Attack of the Squares");
  35.         lmainMenu.setFont(new Font("Undercover", Font.BOLD, 85));
  36.         JPanel panel = new JPanel();
  37.         panel.add(lmainMenu);
  38.         JPanel game = new JPanel();
  39.         game.setVisible(false);
  40.         f.add(panel);
  41.         f.add(game);
  42.         play = new JButton("Play");
  43.         difficulty = new JButton("Difficulty");
  44.         credits = new JButton("Credits");
  45.        
  46.         play.setPreferredSize(new Dimension(100, 50));
  47.         play.setBackground(Color.green);
  48.        
  49.         difficulty.setPreferredSize(new Dimension(100, 50));
  50.         difficulty.setBackground(Color.green);
  51.        
  52.         credits.setPreferredSize(new Dimension(100, 50));
  53.         credits.setBackground(Color.green);
  54.        
  55.         panel.add(play);
  56.          panel.add(difficulty);
  57.          panel.add(credits);
  58.          play.addActionListener(this);
  59.          difficulty.addActionListener(this);
  60.          credits.addActionListener(this);
  61.          panel.setBackground(new Color(204, 255, 51));
  62.          this.add(panel);
  63.        
  64.     }
  65.    
  66.  
  67.     public void actionPerformed(ActionEvent event) {
  68.    
  69.         if(event.getSource() == credits){
  70.             JOptionPane.showMessageDialog(this, "Attack of the Squares was developed by Bryan, Jax, and Will");
  71.            
  72.         }
  73.         if(event.getSource() == play){
  74.             JOptionPane.showMessageDialog(this, "You thought ;)");
  75.     }
  76.        
  77.         if(event.getSource() == difficulty){
  78.             JOptionPane.showMessageDialog(this, "Just press 9");
  79.            
  80.         }
  81.    
  82.    
  83.    
  84.     }
  85.    
  86.    
  87.    
  88.  
  89.    
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement