martaczaska

Menu_1

Jan 2nd, 2020
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.95 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.  
  18.         private JButton łatwy;
  19.         private JButton średni;
  20.         private JButton trudny;
  21.  
  22.         int w = 1024;
  23.         int h = 768;
  24.         int time = 1;
  25.  
  26.         public Menu(int w_okno, int h_okno){
  27.             setLayout(new GridLayout(3, 1,200, 200));
  28.  
  29.             int WIDTH = 200;
  30.             int HEIGHT = 130;
  31.  
  32.             instrukcja = new JButton("Instrukcja");
  33.             start = new JButton("Start");
  34.             wyjscie = new JButton("Wyjście");
  35.  
  36.             instrukcja.addActionListener(this);
  37.             start.addActionListener(this);
  38.             wyjscie.addActionListener(this);
  39.  
  40.             setPreferredSize(new Dimension(WIDTH, HEIGHT));
  41.             add(instrukcja);
  42.             add(start);
  43.             add(wyjscie);
  44.         }
  45.        
  46.         public void poziomy(String poziom){
  47.            
  48.         }
  49.  
  50.         public void actionPerformed(ActionEvent e){
  51.             Object source = e.getSource();
  52.  
  53.             if(source == instrukcja) {
  54.  
  55.                 JOptionPane.showMessageDialog(null, "Tutaj będzie cała instrukcja do grania");   //DZIAŁA, NAJS
  56.  
  57.             }
  58.  
  59.             else if(source == start) {
  60.  
  61.                 public static void poziomy(){
  62.  
  63.                     setLayout(new GridLayout(3, 1, 200, 200));
  64.  
  65.                     łatwy = new JButton("łatwy");
  66.                     średni = new JButton("średni");
  67.                     trudny = new JButton("trudny");
  68.  
  69.                     łatwy.addActionListener(this);
  70.                     średni.addActionListener(this);
  71.                     trudny.addActionListener(this);
  72.  
  73.                     setPreferredSize(new Dimension(WIDTH, HEIGHT));
  74.                     add(łatwy);
  75.                     add(średni);
  76.                     add(trudny);
  77.  
  78.  
  79.                     if (time != 0) {
  80.                         add(new etap_1(w, h));
  81.  
  82.                         long czas = System.currentTimeMillis();
  83.                         int i = 5;
  84.  
  85.                         while (i >= 0) {
  86.                             if (System.currentTimeMillis() - czas > 1000) {
  87.                                 System.out.println(i--);
  88.                                 czas = System.currentTimeMillis();
  89.                             }
  90.                         }
  91.  
  92.                         System.out.println("Bam");
  93.                     }
  94.  
  95.                 }
  96.  
  97.  
  98.             }
  99.  
  100.             else if(source == wyjscie){
  101.                 //frame.dispose();
  102.                 System.exit(0);    //DZIAŁA, NAJS
  103.             }
  104.  
  105.         }
  106.  
  107.         //setVisible(true);
  108.  
  109.     }
Advertisement
Add Comment
Please, Sign In to add comment