keep getting this error, but it don’t appear from time to time, there are times that it don’t and there are times when this appears. I have a timer that is shown in the gui but I don’t use invokelater to show the timer to gui, all I do is that I use MTTextArea to make it appear in the gui. Well, I can’t point out the problem because it says there the arraylist is unknown source… I’m a beginner programmer and it’s the first time I encountered this kind of exception… please somebody explain to me what is going on? and why this exception keeps on appearing? And I don’t have an arraylist in my code by the way…
here's the actual code that I believe where I'm getting the error: (it's not the full code though... because it is very long you might get headaches )
public class TimeClass extends TimerTask {
int counter;
PImage imggo = mtApp.loadImage("Puzzle/datas/gameover.png");
MTRectangle re = new MTRectangle(mtApp, 400, 200);
PImage ta = mtApp.loadImage("Puzzle/datas/tryagain.png");
final MTRectangle tryAgain = new MTRectangle(mtApp,
(mtApp.width / 2) - 150, (mtApp.height / 2), 0, 300, 100);
final MTTextArea yestry = new MTTextArea(mtApp, font);
final MTTextArea noexit = new MTTextArea(mtApp, font);
public TimeClass(int counter) {
this.counter = counter;
}
private long TimeInSeconds = 0, TimeInMinutes = 0;
@Override
public void run() {
try{
TimeInSeconds++;
if (TimeInSeconds < 10) {
timercount.setText(" 0" + TimeInSeconds);
} else {
timercount.setText(" " + TimeInSeconds);
}
if (TimeInSeconds == 59) {
TimeInSeconds = 0;
TimeInMinutes++;
timercount2.setText(TimeInMinutes + " : ");
}
if (TimeInMinutes == 60) {
TimeInMinutes = 0;
}
}catch (IndexOutOfBoundsException ex){
System.out.println(ex.getCause());
}
if (horizontalTiles == 3 && TimeInSeconds == 1) {
timer.cancel();
timer.purge();
puzzleGroup.setVisible(false);
for (MTComponent c : puzzleGroup.getChildren()) {
c.destroy();
}
puzzleGroup.destroy();
System.out.println("GameOver");
System.out.println("RECORD: " + timercount.getText());
re.setPositionGlobal(new Vector3D(mtApp.width / 2,
mtApp.height / 2 - 150));
re.setNoStroke(true);
re.setTexture(imggo);
re.setVisible(true);
tryAgain.setPickable(false);
tryAgain.setNoStroke(true);
tryAgain.setTexture(ta);
tryAgain.setVisible(true);
yestry.setFillColor(new MTColor(0, 255, 255, 150));
yestry.setStrokeColor(new MTColor(0, 255, 255, 200));
yestry.setText("Yes");
clearAllGestures(yestry);
yestry.setVisible(true);
getCanvas().addChild(yestry);
yestry.setPositionGlobal(new Vector3D((mtApp.width / 2) - 100,
(mtApp.height / 2) + 200, 0));
yestry.registerInputProcessor(new TapProcessor(mtApp, 2000));
yestry.addGestureListener(TapProcessor.class,
new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
TapEvent th = (TapEvent) ge;
switch (th.getId()) {
case TapEvent.GESTURE_STARTED:
break;
case TapEvent.GESTURE_UPDATED:
break;
case TapEvent.GESTURE_ENDED:
noexit.destroy();
mtApp.pushScene();
tryagain = new puzzlescene(mtApp,
"The Brain Tickler");
mtApp.addScene(tryagain);
mtApp.changeScene(tryagain);
System.out.println("stop now");
break;
default:
break;
}
return false;
}
});
noexit.setFillColor(new MTColor(0, 255, 255, 150));
noexit.setStrokeColor(new MTColor(0, 255, 255, 200));
noexit.setText("Exit");
clearAllGestures(noexit);
noexit.setVisible(true);
getCanvas().addChild(noexit);
noexit.setPositionGlobal(new Vector3D((mtApp.width / 2) + 100,
(mtApp.height / 2) + 200, 0));
noexit.registerInputProcessor(new TapProcessor(mtApp, 2000));
noexit.addGestureListener(TapProcessor.class,
new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
TapEvent th = (TapEvent) ge;
switch (th.getId()) {
case TapEvent.GESTURE_STARTED:
break;
case TapEvent.GESTURE_UPDATED:
break;
case TapEvent.GESTURE_ENDED:
yestry.destroy();
tryagain.destroy();
record.destroy();
System.exit(0);
break;
default:
break;
}
return false;
}
});
getCanvas().addChild(tryAgain);
getCanvas().addChild(yestry);
getCanvas().addChild(noexit);
getCanvas().addChild(re);
}
if (horizontalTiles == 4 && TimeInSeconds == 4) {
timer.cancel();
timer.purge();
puzzleGroup.setVisible(false);
puzzleGroup.setVisible(false);
for (MTComponent c : puzzleGroup.getChildren()) {
c.destroy();
}
puzzleGroup.destroy();
getscore(counter);
System.out.println("Score: " + score);
System.out.println("RECORD: " + timercount.getText());
re.setPositionGlobal(new Vector3D(mtApp.width / 2,
mtApp.height / 2 - 150));
re.setNoStroke(true);
re.setTexture(imggo);
re.setVisible(true);
tryAgain.setPickable(false);
tryAgain.setNoStroke(true);
tryAgain.setTexture(ta);
tryAgain.setVisible(true);
yestry.setFillColor(new MTColor(0, 255, 255, 150));
yestry.setStrokeColor(new MTColor(0, 255, 255, 200));
yestry.setText("Yes");
clearAllGestures(yestry);
yestry.setVisible(true);
getCanvas().addChild(yestry);
yestry.setPositionGlobal(new Vector3D((mtApp.width / 2) - 100,
(mtApp.height / 2) + 200, 0));
yestry.registerInputProcessor(new TapProcessor(mtApp, 2000));
yestry.addGestureListener(TapProcessor.class,
new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
TapEvent th = (TapEvent) ge;
switch (th.getId()) {
case TapEvent.GESTURE_STARTED:
break;
case TapEvent.GESTURE_UPDATED:
break;
case TapEvent.GESTURE_ENDED:
noexit.destroy();
mtApp.pushScene();
tryagain = new puzzlescene(mtApp,
"The Brain Tickler");
mtApp.addScene(tryagain);
mtApp.changeScene(tryagain);
System.out.println("stop now");
break;
default:
break;
}
return false;
}
});
noexit.setFillColor(new MTColor(0, 255, 255, 150));
noexit.setStrokeColor(new MTColor(0, 255, 255, 200));
noexit.setText("Exit");
clearAllGestures(noexit);
noexit.setVisible(true);
getCanvas().addChild(noexit);
noexit.setPositionGlobal(new Vector3D((mtApp.width / 2) + 100,
(mtApp.height / 2) + 200, 0));
noexit.registerInputProcessor(new TapProcessor(mtApp, 2000));
noexit.addGestureListener(TapProcessor.class,
new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
TapEvent th = (TapEvent) ge;
switch (th.getId()) {
case TapEvent.GESTURE_STARTED:
break;
case TapEvent.GESTURE_UPDATED:
break;
case TapEvent.GESTURE_ENDED:
yestry.destroy();
tryagain.destroy();
record.destroy();
System.exit(0);
break;
default:
break;
}
return false;
}
});
getCanvas().addChild(tryAgain);
getCanvas().addChild(yestry);
getCanvas().addChild(noexit);
getCanvas().addChild(re);
}
if (horizontalTiles == 5 && TimeInSeconds == 5) {
for (MTComponent c : puzzleGroup.getChildren()) {
c.destroy();
}
puzzleGroup.destroy();
timer.cancel();
timer.purge();
puzzleGroup.setVisible(false);
getscore(counter);
System.out.println("Score: " + score);
System.out.println("RECORD: " + timercount.getText());
re.setPositionGlobal(new Vector3D(mtApp.width / 2,
mtApp.height / 2 - 150));
re.setNoStroke(true);
re.setTexture(imggo);
re.setVisible(true);
tryAgain.setPickable(false);
tryAgain.setNoStroke(true);
tryAgain.setTexture(ta);
tryAgain.setVisible(true);
yestry.setFillColor(new MTColor(0, 255, 255, 150));
yestry.setStrokeColor(new MTColor(0, 255, 255, 200));
yestry.setText("Yes");
clearAllGestures(yestry);
yestry.setVisible(true);
getCanvas().addChild(yestry);
yestry.setPositionGlobal(new Vector3D((mtApp.width / 2) - 100,
(mtApp.height / 2) + 200, 0));
yestry.registerInputProcessor(new TapProcessor(mtApp, 2000));
yestry.addGestureListener(TapProcessor.class,
new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
TapEvent th = (TapEvent) ge;
switch (th.getId()) {
case TapEvent.GESTURE_STARTED:
break;
case TapEvent.GESTURE_UPDATED:
break;
case TapEvent.GESTURE_ENDED:
noexit.destroy();
mtApp.pushScene();
tryagain = new puzzlescene(mtApp,
"The Brain Tickler");
mtApp.addScene(tryagain);
mtApp.changeScene(tryagain);
System.out.println("stop now");
break;
default:
break;
}
return false;
}
});
noexit.setFillColor(new MTColor(0, 255, 255, 150));
noexit.setStrokeColor(new MTColor(0, 255, 255, 200));
noexit.setText("Exit");
clearAllGestures(noexit);
noexit.setVisible(true);
getCanvas().addChild(noexit);
noexit.setPositionGlobal(new Vector3D((mtApp.width / 2) + 100,
(mtApp.height / 2) + 200, 0));
noexit.registerInputProcessor(new TapProcessor(mtApp, 2000));
noexit.addGestureListener(TapProcessor.class,
new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
TapEvent th = (TapEvent) ge;
switch (th.getId()) {
case TapEvent.GESTURE_STARTED:
break;
case TapEvent.GESTURE_UPDATED:
break;
case TapEvent.GESTURE_ENDED:
yestry.destroy();
tryagain.destroy();
record.destroy();
System.exit(0);
break;
default:
break;
}
return false;
}
});
getCanvas().addChild(tryAgain);
getCanvas().addChild(yestry);
getCanvas().addChild(noexit);
getCanvas().addChild(re);
}
System.out.println("Time is: " + TimeInMinutes + " : "
+ TimeInSeconds);
}
and if you really have a free time... here's the full code... but I need to warn you that it won't run because you still need the pictures I used and the library I'm using which is mt4j ..