Mercurial > hg > pub > prymula > com
view anielskiepuzzle/src/trefle/Mouse.java @ 2:cf2cb71d31dd
immposiblerush-0.230919-0.2
author | prymula <prymula76@outlook.com> |
---|---|
date | Tue, 26 Sep 2023 21:50:44 +0200 |
parents | 2787f5e749ae |
children |
line wrap: on
line source
package trefle; import java.awt.Canvas; import java.awt.Graphics; import javax.swing.JFrame; import java.awt.event.MouseListener; import java.awt.event.MouseEvent; public class Mouse implements MouseListener { int x,y,px,py; int tw,th; Trefle trefle; boolean click = false; @Override public void mousePressed(MouseEvent e){ System.out.println("Mysz nacisnieta - liczba klikiniec:"+e.getClickCount()+" wspolrzedne x: "+e.getX()+" y: "+e.getY()); x=e.getX(); y=e.getY(); click=true; //trefle.repaint(); } @Override public void mouseReleased(MouseEvent e){ System.out.println("Mysz zwolniona - liczba klikiniec:"+e.getClickCount()+" wspolrzedne x: "+e.getX()+" y: "+e.getY()); px=e.getX(); py=e.getY(); click=false; //trefle.repaint(); } @Override public void mouseEntered(MouseEvent e){ System.out.println("Wprowadzono mysz"); x=e.getX(); y=e.getY(); px=e.getX(); py=e.getY(); } @Override public void mouseExited(MouseEvent e){ System.out.println("Mysz wyszla:"); } @Override public void mouseClicked(MouseEvent e){ System.out.println("Kliknieto mysza - liczba klikniec:"+e.getClickCount()); System.out.println("Klikinito klawiszem:"+e.getButton()); click=true; //trefle.repaint(); } public Coordinate getCell(){ Coordinate cor = new Coordinate(x,y,click); //return y*4+x; return cor; } public Coordinate putCell() { Coordinate cor = new Coordinate(px,py,click); //return py*4+px; return cor; } public void set (int _tw, int _th){ tw=_tw; th=_th; } public void setCanvas(Trefle t){ trefle = t; } }