martaczaska

Menu_3

Jan 3rd, 2020
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.77 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,200, 200));
  25.  
  26.             int WIDTH = 200;
  27.             int HEIGHT = 130;
  28.  
  29.             instrukcja = new JButton("Instrukcja");
  30.             start = new JButton("Start");
  31.             wyjscie = new JButton("Wyjście");
  32.  
  33.             instrukcja.addActionListener(this);
  34.             start.addActionListener(this);
  35.             wyjscie.addActionListener(this);
  36.  
  37.             setPreferredSize(new Dimension(WIDTH, HEIGHT));
  38.             add(instrukcja);
  39.             add(start);
  40.             add(wyjscie);
  41.         }
  42.  
  43.  
  44.         public void actionPerformed(ActionEvent e){
  45.             Object source = e.getSource();
  46.  
  47.             if(source == instrukcja) {
  48.  
  49.                 JOptionPane.showMessageDialog(null, "Tutaj będzie cała instrukcja do grania");   //DZIAŁA, NAJS
  50.  
  51.             }
  52.  
  53.             else if(source == start) {
  54.                 setLayout(new GridLayout(1,1));
  55.                 Etap_1 e_1 = new Etap_1();
  56.                 add(e_1);
  57.                 setVisible(true);
  58.             }
  59.  
  60.             else if(source == wyjscie){
  61.                 //frame.dispose();
  62.                 System.exit(0);    //DZIAŁA, NAJS
  63.             }
  64.  
  65.         }
  66.  
  67.         //setVisible(true);
  68.  
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment