Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class Etap_1 extends JPanel implements ActionListener {
- //public String litera = "";
- public int czas = 1;
- JButton łatwy;
- JButton średni;
- JButton trudny;
- public Etap_1(){
- setLayout(new GridLayout(3, 1, 200, 200));
- int WIDTH = 200;
- int HEIGHT = 130;
- łatwy = new JButton("łatwy");
- średni = new JButton("średni");
- trudny = new JButton("trudny");
- łatwy.addActionListener(this);
- średni.addActionListener(this);
- trudny.addActionListener(this);
- //setPreferredSize(new Dimension(WIDTH, HEIGHT));
- add(łatwy);
- add(średni);
- add(trudny);
- }
- public void actionPerformed(ActionEvent f){
- Object poziom = f.getSource();
- if(poziom == łatwy){
- czas = 30;
- System.out.println("tutaj!");
- odliczanie(czas);
- }
- else if(poziom == średni){
- czas = 20;
- odliczanie(czas);
- }
- else if(poziom == trudny){
- czas = 10;
- odliczanie(czas);
- }
- }
- private void odliczanie(int czas){
- long czas_teraz = System.currentTimeMillis();
- while(czas >= 0){
- if(System.currentTimeMillis() - czas_teraz > 1000){
- System.out.println(czas--);
- czas_teraz= System.currentTimeMillis();
- }
- }
- System.out.println("Bam");
- }
Advertisement
Add Comment
Please, Sign In to add comment