martaczaska

Menu_4

Jan 3rd, 2020
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. package com.company;
  2.  
  3. import javax.swing.*;
  4. import java.awt.*;
  5. import java.awt.event.*;
  6. import javax.swing.*;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import javax.swing.JButton;
  10. import javax.swing.JPanel;
  11.  
  12. public class Menu extends JPanel implements ActionListener{
  13.  
  14.         private JButton instrukcja;
  15.         private JButton start;
  16.         private JButton wyjscie;
  17.         public Object poziom;
  18.  
  19.         int w_okno = 1024;
  20.         int h_okno = 768;
  21.         public int time = 1;
  22.  
  23.         public Menu(){
  24.             setLayout(new GridLayout(3, 1,10, 200));
  25.             //setLayout(new FlowLayout(1,300, 100));
  26.             setBackground(Color.pink);
  27.  
  28.             int WIDTH = 20;
  29.             int HEIGHT = 13;
  30.  
  31.             instrukcja = new JButton("Instrukcja");
  32.             start = new JButton("Start");
  33.             wyjscie = new JButton("Wyjście");
  34.  
  35.             instrukcja.addActionListener(this);
  36.             start.addActionListener(this);
  37.             wyjscie.addActionListener(this);
  38.  
  39.             //setPreferredSize(new Dimension(WIDTH, HEIGHT));
  40.             add(instrukcja);
  41.             add(start);
  42.             add(wyjscie);
  43.         }
  44.  
  45.  
  46.         public void actionPerformed(ActionEvent e){
  47.             Object source = e.getSource();
  48.  
  49.             if(source == instrukcja) {
  50.  
  51.                 JOptionPane.showMessageDialog(null, "Tutaj będzie cała instrukcja do grania");   //DZIAŁA, NAJS
  52.  
  53.             }
  54.  
  55.             else if(source == start) {
  56.                 setLayout(new GridLayout(1,1));
  57.                 System.out.println("tutaj!");
  58.                 //Etap_1 e_1 = new Etap_1();
  59.                 //add(e_1);
  60.                 add(new Etap_1());
  61.                 System.out.println("tutaj też jestem!");
  62.                 setVisible(true);
  63.             }
  64.  
  65.             else if(source == wyjscie){
  66.                 System.exit(0);    //DZIAŁA, NAJS
  67.             }
  68.  
  69.         }
  70.  
  71.         //setVisible(true);
  72.  
  73.     }
Advertisement
Add Comment
Please, Sign In to add comment