Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tetris;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.GridLayout;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- public class Main_Frame extends JFrame{
- JButton button1;
- JButton button2;
- JButton button3;
- JButton button4;
- JLabel label;
- public Main_Frame(){
- Listener_Adapter x = new Listener_Adapter();
- JFrame window = new JFrame();
- window.setTitle("Tetris");
- window.addWindowListener(x);
- window.setSize(200,400);
- window.setLayout(new BorderLayout());
- JPanel panel = new JPanel(new GridLayout(5,1, 0, 0));
- panel.setBackground(Color.ORANGE);
- button1 = new JButton("Play!");
- button1.setBackground(Color.RED);
- button2 = new JButton("Highscore");
- button2.setBackground(Color.BLUE);
- button3 = new JButton("Controls");
- button3.setBackground(Color.GREEN);
- button4 = new JButton("Exit");
- button4.setBackground(Color.YELLOW);
- label = new JLabel(new ImageIcon("G://tetrisgame/src/tetris/tetris_header.jpg"));
- panel.add(label);
- panel.add(button1);
- panel.add(button2);
- panel.add(button3);
- panel.add(button4);
- window.add(panel, BorderLayout.CENTER);
- button1.setActionCommand("1");
- button2.setActionCommand("2");
- button3.setActionCommand("3");
- button4.setActionCommand("4");
- button1.addActionListener(x);
- button2.addActionListener(x);
- button3.addActionListener(x);
- button4.addActionListener(x);
- window.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement