annotate anielskiepuzzle/src/trefle/Mouse.java @ 14:49dd434149cd

README.md immposiblerush
author prymula <prymula76@outlook.com>
date Sat, 10 Feb 2024 20:40:34 +0100
parents 2787f5e749ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1
prymula <prymula76@outlook.com>
parents:
diff changeset
2
prymula <prymula76@outlook.com>
parents:
diff changeset
3 package trefle;
prymula <prymula76@outlook.com>
parents:
diff changeset
4
prymula <prymula76@outlook.com>
parents:
diff changeset
5 import java.awt.Canvas;
prymula <prymula76@outlook.com>
parents:
diff changeset
6 import java.awt.Graphics;
prymula <prymula76@outlook.com>
parents:
diff changeset
7 import javax.swing.JFrame;
prymula <prymula76@outlook.com>
parents:
diff changeset
8 import java.awt.event.MouseListener;
prymula <prymula76@outlook.com>
parents:
diff changeset
9 import java.awt.event.MouseEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
10
prymula <prymula76@outlook.com>
parents:
diff changeset
11
prymula <prymula76@outlook.com>
parents:
diff changeset
12 public class Mouse implements MouseListener {
prymula <prymula76@outlook.com>
parents:
diff changeset
13 int x,y,px,py;
prymula <prymula76@outlook.com>
parents:
diff changeset
14 int tw,th;
prymula <prymula76@outlook.com>
parents:
diff changeset
15 Trefle trefle;
prymula <prymula76@outlook.com>
parents:
diff changeset
16 boolean click = false;
prymula <prymula76@outlook.com>
parents:
diff changeset
17
prymula <prymula76@outlook.com>
parents:
diff changeset
18
prymula <prymula76@outlook.com>
parents:
diff changeset
19 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
20 public void mousePressed(MouseEvent e){
prymula <prymula76@outlook.com>
parents:
diff changeset
21 System.out.println("Mysz nacisnieta - liczba klikiniec:"+e.getClickCount()+" wspolrzedne x: "+e.getX()+" y: "+e.getY());
prymula <prymula76@outlook.com>
parents:
diff changeset
22 x=e.getX();
prymula <prymula76@outlook.com>
parents:
diff changeset
23 y=e.getY();
prymula <prymula76@outlook.com>
parents:
diff changeset
24 click=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
25 //trefle.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
26 }
prymula <prymula76@outlook.com>
parents:
diff changeset
27 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
28 public void mouseReleased(MouseEvent e){
prymula <prymula76@outlook.com>
parents:
diff changeset
29 System.out.println("Mysz zwolniona - liczba klikiniec:"+e.getClickCount()+" wspolrzedne x: "+e.getX()+" y: "+e.getY());
prymula <prymula76@outlook.com>
parents:
diff changeset
30 px=e.getX();
prymula <prymula76@outlook.com>
parents:
diff changeset
31 py=e.getY();
prymula <prymula76@outlook.com>
parents:
diff changeset
32 click=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
33 //trefle.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
34 }
prymula <prymula76@outlook.com>
parents:
diff changeset
35 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
36 public void mouseEntered(MouseEvent e){
prymula <prymula76@outlook.com>
parents:
diff changeset
37 System.out.println("Wprowadzono mysz");
prymula <prymula76@outlook.com>
parents:
diff changeset
38 x=e.getX();
prymula <prymula76@outlook.com>
parents:
diff changeset
39 y=e.getY();
prymula <prymula76@outlook.com>
parents:
diff changeset
40 px=e.getX();
prymula <prymula76@outlook.com>
parents:
diff changeset
41 py=e.getY();
prymula <prymula76@outlook.com>
parents:
diff changeset
42 }
prymula <prymula76@outlook.com>
parents:
diff changeset
43 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
44 public void mouseExited(MouseEvent e){
prymula <prymula76@outlook.com>
parents:
diff changeset
45 System.out.println("Mysz wyszla:");
prymula <prymula76@outlook.com>
parents:
diff changeset
46 }
prymula <prymula76@outlook.com>
parents:
diff changeset
47 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
48 public void mouseClicked(MouseEvent e){
prymula <prymula76@outlook.com>
parents:
diff changeset
49 System.out.println("Kliknieto mysza - liczba klikniec:"+e.getClickCount());
prymula <prymula76@outlook.com>
parents:
diff changeset
50 System.out.println("Klikinito klawiszem:"+e.getButton());
prymula <prymula76@outlook.com>
parents:
diff changeset
51 click=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
52 //trefle.repaint();
prymula <prymula76@outlook.com>
parents:
diff changeset
53 }
prymula <prymula76@outlook.com>
parents:
diff changeset
54 public Coordinate getCell(){
prymula <prymula76@outlook.com>
parents:
diff changeset
55 Coordinate cor = new Coordinate(x,y,click); //return y*4+x;
prymula <prymula76@outlook.com>
parents:
diff changeset
56 return cor;
prymula <prymula76@outlook.com>
parents:
diff changeset
57 }
prymula <prymula76@outlook.com>
parents:
diff changeset
58 public Coordinate putCell() {
prymula <prymula76@outlook.com>
parents:
diff changeset
59 Coordinate cor = new Coordinate(px,py,click); //return py*4+px;
prymula <prymula76@outlook.com>
parents:
diff changeset
60 return cor;
prymula <prymula76@outlook.com>
parents:
diff changeset
61 }
prymula <prymula76@outlook.com>
parents:
diff changeset
62 public void set (int _tw, int _th){
prymula <prymula76@outlook.com>
parents:
diff changeset
63 tw=_tw;
prymula <prymula76@outlook.com>
parents:
diff changeset
64 th=_th;
prymula <prymula76@outlook.com>
parents:
diff changeset
65 }
prymula <prymula76@outlook.com>
parents:
diff changeset
66 public void setCanvas(Trefle t){
prymula <prymula76@outlook.com>
parents:
diff changeset
67 trefle = t;
prymula <prymula76@outlook.com>
parents:
diff changeset
68 }
prymula <prymula76@outlook.com>
parents:
diff changeset
69 }