view anielskiepuzzle/src/trefle/Mouse.java @ 10:4dc186728822

immposiblerush-0.230919-2
author prymula <prymula76@outlook.com>
date Sun, 04 Feb 2024 23:27:00 +0100
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;
    }
}