martaczaska

Etap_1(ten prawdziwy)_5

Jan 4th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.76 KB | None | 0 0
  1. package com.company;
  2.  
  3. import javax.imageio.ImageIO;
  4. import javax.swing.*;
  5. import java.awt.*;
  6. import java.awt.image.BufferedImage;
  7. import java.io.File;
  8. import java.io.IOException;
  9. import java.util.Random;
  10. import java.util.Scanner;
  11. import java.util.concurrent.Flow;
  12.  
  13. public class Etap_1 extends JPanel{
  14.  
  15.     public static Image[]kolo;
  16.     public String[] litery = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "R", "S", "T", "U", "W", "Y", "Z"};   // spolgloski[22] (23 ale od 0 do 22)
  17.     public String wybrana_zol = "";
  18.     public String wybrana_kolor = "";
  19.  
  20.     public BufferedImage image_1;
  21.     public BufferedImage image_2;
  22.     public BufferedImage kolo_1;
  23.     public BufferedImage kolo_2;
  24.     public BufferedImage tlo_1;
  25.  
  26.  
  27.     public Etap_1(){
  28.         setLayout(null);
  29.  
  30.         Random losowa = new Random();
  31.  
  32.         int polozenie = losowa.nextInt(2);
  33.         int tab_kolo_zol = losowa.nextInt(7);
  34.         int tab_kolo_kolor = losowa.nextInt(7);
  35.         int nr_litery_1 = losowa.nextInt(22);
  36.         int nr_litery_2 = losowa.nextInt(22);
  37.  
  38.         wybrana_zol = litery[nr_litery_1];
  39.         wybrana_kolor = litery[nr_litery_2];
  40.  
  41.         File zdjecie_1 = new File("zdjecia/zolte/" + wybrana_zol + ".png");
  42.         File zdjecie_2 = new File("zdjecia/kolorowe/" + wybrana_kolor + ".png");
  43.         File zdjecie_3 = new File("zdjecia/tlo_GRA_1.png");
  44.  
  45.         try{
  46.             image_1 = ImageIO.read(zdjecie_1);
  47.             image_2 = ImageIO.read(zdjecie_2);
  48.             tlo_1 = ImageIO.read(zdjecie_3);
  49.  
  50.         }
  51.         catch(IOException e){
  52.             System.err.println("Blad odczytu obrazkΓ³w");
  53.         }
  54.  
  55.  
  56.         if(polozenie == 0){
  57.             kolo_1 = image_1;
  58.             kolo_2 = image_2;
  59.         }
  60.         else if(polozenie == 1){
  61.             kolo_1 = image_2;
  62.             kolo_2 = image_1;
  63.         }
  64.  
  65.         JTextField jt = new JTextField("T");
  66.         jt.setBounds(320, 650, 370, 70);
  67.         add(jt);
  68.        
  69.  
  70.         Scanner scan = new Scanner(System.in);
  71.         System.out.println("Podaj literΔ™?");
  72.         String firstName = scan.nextLine();
  73.         jt.equals(firstName);
  74.  
  75.  
  76.  
  77.     }
  78.  
  79.     private void odliczanie(int czas){
  80.         long czas_teraz = System.currentTimeMillis();
  81.         while(czas >= 0){
  82.             if(System.currentTimeMillis() - czas_teraz > 1000){
  83.                 System.out.println(czas--);
  84.                 czas_teraz= System.currentTimeMillis();
  85.             }
  86.         }
  87.         System.out.println("Bam");
  88.     }
  89.  
  90.     public void paintComponent(Graphics graphic) {
  91.         Graphics2D g2d = (Graphics2D) graphic;
  92.         g2d.drawImage(tlo_1, 0, 0, this);
  93.         g2d.drawImage(kolo_1, 100, 180, this);
  94.         g2d.drawImage(kolo_2, 600, 180, this);
  95.  
  96.     }
  97.  
  98. }
Add Comment
Please, Sign In to add comment