guys im wroted this code. When i was writing i have problem when i want to write "e" in argument (void Record). Well Eclipse sugereting me null. I change "e" on "null" but now. When im compiling program has error:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.SwingUtilities.isLeftMouseButton(SwingUtilities.java:796)
at Clicklu.Clicklu.Action.mousePressed(Action.java:14)
at Clicklu.Clicklu.Action.Record(Action.java:26)
at Clicklu.Clicklu.Main.main(Main.java:11)
import java.awt.event.MouseEvent;
import javax.swing.SwingUtilities;
public class Action {
LeftMouseClick leftMouseClick = new LeftMouseClick();
RightMouseClick rightMouseClick = new RightMouseClick();
CoursorMove tr = new CoursorMove();
public void mousePressed(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e)) {
leftMouseClick.addNewLeftMouseClick();
} else if (SwingUtilities.isRightMouseButton(e)) {
rightMouseClick.addNewRightMouseClick();
}
}
public void Record()
{
for (int i = 0; i < 10000; i++) {
Action action = new Action();
action.mousePressed(null);
tr.gettingMouseCoordinates();
}
}
public void Play() {
for (int i = 0; i < 10000; i++) {
int leftindex = 0;
int rightindex = 0;
tr.moveCoursor();
if (tr.getCoordinate(i).equals(leftMouseClick.getCoordinate(leftindex))) {
leftMouseClick.leftMouseClick();
continue;
}
else if (tr.getCoordinate(i).equals(rightMouseClick.getCoordinate(rightindex))) {
rightMouseClick.rightMouseClick();
continue;
}
}
}
}
Main class:
public class Main {
public static void main(String[] args) {
// CoursorMove triup = new CoursorMove();
// triup.gettingMouseCoordinates();
// triup.moveCoursor();
Action test = new Action();
test.Record();
test.Play();
}
}