how can i call another class using MouseListener? this my class using Implements MouseListener
public class MouseInput implements MouseListener {
@Override
public void mouseClicked (MouseEvent me){
}
@Override
public void mousePressed (MouseEvent me){
}
@Override
public void mouseReleased (MouseEvent me){
int x = me.getX();
int y = me.getY();
if (me.getButton() == MouseEvent.BUTTON1){
if (x>50 && x<450 && y>400 && y<450){
if(State.ANIMATED){
State.ANIMATED = false;
}else{
State.ANIMATED = true;
}
}
}
}
@Override
public void mouseEntered (MouseEvent me){
State.ANIMATED = true;
}
@Override
public void mouseExited (MouseEvent me){
State.ANIMATED = false;
}
and i want to call other class, anyone can help me? thank you
You can make the class known to your class MouseInput. Create a constructor and a member variable in the class and assign it. Then use from any of the methods you have.
public class MouseInput implements MouseListener {
YourClassName yourClassName;
public MouseInput(YourClassName yourClassName ) {
this.yourClassName = yourClassName;
}
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.