伙计们我写了这个代码。当我写作时,我有问题,当我想在论证中写“e”(无效记录)。 Eclipse Eclipse让我无效。我在“null”上更改“e”但现在。当我编译程序有错误时:
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;
}
}
}
}
主要课程:
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();
}
}