Mercurial > hg > pub > prymula > com
diff anielskiepuzzle/src/trefle/Mouse.java @ 0:2787f5e749ae
INIT
author | prymula <prymula76@outlook.com> |
---|---|
date | Thu, 21 Sep 2023 22:33:57 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/anielskiepuzzle/src/trefle/Mouse.java Thu Sep 21 22:33:57 2023 +0200 @@ -0,0 +1,69 @@ + + +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; + } +}