I've got a JPanel class called Board with a static subclass, MouseHanlder, which tracks the mouse position along the appropriate listener in Board. My Board class has fields pointerX and pointerY.
How do i pass the e.getX() and e.getY() from the MouseHandler subclass to its super class JPanel? I tried with getters, setters, super, and cant get the data transfer between subclass and parent class. I'm certain it's a concept issue, but im stuck.
Thanks!
Due popular demand, some code. This is the code without any atempt of passing :
public class Board extends JPanel {
int x; // Mouse pointer fields.
int y;
public Board() {
blah blah
MouseHandler handler = new MouseHandler();
addMouseMotionListener(handler);
}
static class MouseHandler implements MouseMotionListener {
int pointerX;
int pointerY;
public void mouseMoved(MouseEvent e) {
i'd like to do something like:
super.x = e.getX();
super.x = e.getY();
or
Board.setX() = e.getX(); // Missing setters below, this is just an example.
Board.setX() = e.getY();
}
}
}