Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Font;
- import javax.swing.SwingUtilities;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JTextField;
- public class GameMainMenu extends JFrame implements ActionListener{
- JButton play, difficulty, credits;
- GameMainMenu(String title){
- super(title);
- this.setSize(2000,1000);
- this.init();
- this.setVisible(true);
- }
- void init(){
- JFrame f = new JFrame();
- JLabel lmainMenu = new JLabel("Attack of the Squares");
- lmainMenu.setFont(new Font("Undercover", Font.BOLD, 85));
- JPanel panel = new JPanel();
- panel.add(lmainMenu);
- JPanel game = new JPanel();
- game.setVisible(false);
- f.add(panel);
- f.add(game);
- play = new JButton("Play");
- difficulty = new JButton("Difficulty");
- credits = new JButton("Credits");
- play.setPreferredSize(new Dimension(100, 50));
- play.setBackground(Color.green);
- difficulty.setPreferredSize(new Dimension(100, 50));
- difficulty.setBackground(Color.green);
- credits.setPreferredSize(new Dimension(100, 50));
- credits.setBackground(Color.green);
- panel.add(play);
- panel.add(difficulty);
- panel.add(credits);
- play.addActionListener(this);
- difficulty.addActionListener(this);
- credits.addActionListener(this);
- panel.setBackground(new Color(204, 255, 51));
- this.add(panel);
- }
- public void actionPerformed(ActionEvent event) {
- if(event.getSource() == credits){
- JOptionPane.showMessageDialog(this, "Attack of the Squares was developed by Bryan, Jax, and Will");
- }
- if(event.getSource() == play){
- JOptionPane.showMessageDialog(this, "You thought ;)");
- }
- if(event.getSource() == difficulty){
- JOptionPane.showMessageDialog(this, "Just press 9");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement