Advertisement
Guest User

Untitled

a guest
Oct 11th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package tetris;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.GridLayout;
  6.  
  7. import javax.swing.ImageIcon;
  8. import javax.swing.JButton;
  9. import javax.swing.JFrame;
  10. import javax.swing.JLabel;
  11. import javax.swing.JPanel;
  12.  
  13. public class Main_Frame extends JFrame{
  14.  
  15.     JButton button1;
  16.     JButton button2;
  17.     JButton button3;
  18.     JButton button4;
  19.     JLabel label;
  20.    
  21.     public Main_Frame(){
  22.         Listener_Adapter x = new Listener_Adapter();
  23.         JFrame window = new JFrame();  
  24.        
  25.         window.setTitle("Tetris");
  26.         window.addWindowListener(x);
  27.         window.setSize(200,400);
  28.         window.setLayout(new BorderLayout());
  29.        
  30.        
  31.                
  32.         JPanel panel = new JPanel(new GridLayout(5,1, 0, 0));
  33.         panel.setBackground(Color.ORANGE);
  34.        
  35.         button1 = new JButton("Play!");
  36.         button1.setBackground(Color.RED);
  37.        
  38.         button2 = new JButton("Highscore");
  39.         button2.setBackground(Color.BLUE);
  40.        
  41.         button3 = new JButton("Controls");
  42.         button3.setBackground(Color.GREEN);
  43.        
  44.         button4 = new JButton("Exit");
  45.         button4.setBackground(Color.YELLOW);
  46.        
  47.         label = new JLabel(new ImageIcon("G://tetrisgame/src/tetris/tetris_header.jpg"));
  48.        
  49.         panel.add(label);
  50.         panel.add(button1);
  51.         panel.add(button2);
  52.         panel.add(button3);
  53.         panel.add(button4);
  54.        
  55.         window.add(panel, BorderLayout.CENTER);
  56.        
  57.         button1.setActionCommand("1");
  58.         button2.setActionCommand("2");
  59.         button3.setActionCommand("3");
  60.         button4.setActionCommand("4");
  61.        
  62.         button1.addActionListener(x);
  63.         button2.addActionListener(x);
  64.         button3.addActionListener(x);
  65.         button4.addActionListener(x);
  66.        
  67.         window.setVisible(true);
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement