Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.util.Scanner;
- import java.util.Random;
- public class Poziomy extends JPanel implements ActionListener {
- //public String litera = "";
- public int czas = 1;
- public int m = 100;
- public int n = 200;
- public int j;
- JButton łatwy;
- JButton sredni;
- JButton trudny;
- public Poziomy(){
- //setLayout(new GridLayout(3, 1, 200, 200));
- //int WIDTH = 200;
- //int HEIGHT = 130;
- setLayout(null);
- łatwy = new JButton("łatwy");
- sredni = new JButton("średni");
- trudny = new JButton("trudny");
- łatwy.addActionListener(this);
- sredni.addActionListener(this);
- trudny.addActionListener(this);
- łatwy.setBounds(320, 100, 300, 80 );
- sredni.setBounds(320, 300, 300, 80);
- trudny.setBounds(320, 500, 300, 80);
- //setPreferredSize(new Dimension(WIDTH, HEIGHT));
- add(łatwy);
- add(sredni);
- add(trudny);
- }
- public void actionPerformed(ActionEvent f){
- Object poziom = f.getSource();
- if(poziom == łatwy){
- czas = 30;
- System.out.println("tutaj!");
- odliczanie(czas);
- while(czas != 0){
- //wyswietlanie();
- }
- }
- else if(poziom == sredni){
- czas = 20;
- odliczanie(czas);
- while(czas != 0){
- //wyswietlanie();
- }
- }
- else if(poziom == trudny){
- Okno noweOkno_2 = new Okno(1024,768);
- CardLayout CL_2 =(CardLayout)(noweOkno_2.karty.getLayout());
- CL_2.show(noweOkno_2.karty, "etap_1");
- czas = 1; //na razie, normalnie czas =10
- odliczanie(czas);
- if(czas != 0){
- //new Etap_1();
- //w pętli wyswietlanie i wpisywanie liter
- }
- else if(czas == 0){
- Okno noweOkno_3 = new Okno(1024,768);
- CardLayout CL_3 =(CardLayout)(noweOkno_3.karty.getLayout());
- CL_3.show(noweOkno_2.karty, "etap_3");
- }
- }
- }
- 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");
- }
- public static Image wez_zdjecie(String nazwa_pliku)
- {
- return new ImageIcon(nazwa_pliku).getImage();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment