SHARE
TWEET

Untitled

a guest Feb 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Gameo;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.Font;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.KeyEvent;
  9. import java.awt.event.KeyListener;
  10. import java.io.File;
  11. import javax.swing.ImageIcon;
  12. import javax.swing.JButton;
  13. import javax.swing.JFrame;
  14. import javax.swing.JLabel;
  15. import javax.swing.JPanel;
  16.  
  17. public class Menu extends JPanel implements ActionListener,KeyListener {
  18.  
  19.     JFrame window = new JFrame();
  20.     JButton playButton = new JButton();
  21.     JButton exitButton = new JButton();
  22.     JLabel infoLabel = new JLabel();
  23.     JLabel centerImageLabel = new JLabel();
  24.     JButton backgroundButton = new JButton();
  25.  
  26.     Font customFont = new Font("Italic",Font.ITALIC,30);
  27.  
  28.     Menu()
  29.     {
  30.         this.setBackground(Color.RED);
  31.         this.setForeground(Color.RED);
  32.         window.add(this);
  33.        
  34.         SoundSharedInstance soundSharedInstance = SoundSharedInstance.getInstance();
  35.         if (!soundSharedInstance.isPlaying()) {
  36.             soundSharedInstance.createAudio(new File("sounds//opening1.wav"));
  37.             soundSharedInstance.startAudio();
  38.         }
  39.            
  40.        
  41.  
  42.         playButton.setBackground(Color.RED);
  43.         playButton.setIcon(new ImageIcon("bilder//play.jpg"));
  44.         playButton.addActionListener(this);
  45.         playButton.addKeyListener(this);
  46.         window.add(playButton,BorderLayout.PAGE_START);
  47.  
  48.         exitButton.setBackground(Color.RED);
  49.         exitButton.setIcon(new ImageIcon("bilder//exit.png"));
  50.         exitButton.addActionListener(this);
  51.         exitButton.addKeyListener(this);
  52.         window.add(exitButton,BorderLayout.PAGE_END);
  53.  
  54.         backgroundButton.setBackground(Color.BLACK);
  55.         backgroundButton.setIcon(new ImageIcon("bilder//story.png"));
  56.         backgroundButton.addActionListener(this);
  57.         backgroundButton.addKeyListener(this);
  58.         window.add(backgroundButton,BorderLayout.WEST);
  59.  
  60.         infoLabel.setText("Subscribe to Pewdiepie and Destroy T-Series!");
  61.         infoLabel.setFont(customFont);
  62.         infoLabel.setOpaque(true);
  63.         infoLabel.setBackground(Color.BLACK);
  64.         infoLabel.setForeground(Color.RED);
  65.         window.add(infoLabel,BorderLayout.EAST);
  66.  
  67.  
  68.         centerImageLabel.setBackground(Color.RED);
  69.         centerImageLabel.setOpaque(true);
  70.         centerImageLabel.setIcon(new ImageIcon("bilder//center.jpg"));
  71.         window.add(centerImageLabel,BorderLayout.CENTER);
  72.  
  73.         window.setUndecorated(true);
  74.         window.setSize(1920,1080);
  75.         window.setVisible(true);
  76.     }
  77.  
  78.     @Override
  79.     public void keyPressed(KeyEvent kp) {
  80.         if(kp.getKeyCode()==KeyEvent.VK_ESCAPE)
  81.         {
  82.             window.dispose();
  83.         }
  84.         else if(kp.getKeyCode()==KeyEvent.VK_ENTER)
  85.         {
  86.             Levels l = new Levels();
  87.         }
  88.     }
  89.  
  90.     @Override
  91.     public void keyReleased(KeyEvent arg0) {
  92.         // TODO Auto-generated method stub
  93.  
  94.     }
  95.  
  96.     @Override
  97.     public void keyTyped(KeyEvent arg0) {
  98.         // TODO Auto-generated method stub
  99.  
  100.     }
  101.  
  102.     @Override
  103.     public void actionPerformed(ActionEvent ae) {
  104.  
  105.         if(ae.getSource()==exitButton) {
  106.  
  107.             window.dispose();
  108.         }
  109.         if(ae.getSource()==playButton) {
  110.  
  111.             window.dispose();
  112.             Levels l = new Levels();            ;
  113.         }
  114.         if(ae.getSource()==backgroundButton) {
  115.              
  116.             window.dispose();
  117.             Backgroundstory bs = new Backgroundstory();          
  118.         }
  119.  
  120.     }
  121. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top