Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
mathilde.33
mathilde.33's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
InstantiationException & Applet not initialized
[3 Replies]
08-Dec-2010 05:09 AM
Forum:
Programming Questions
Hi everyone,
I'm new to processing (and Java). I'm trying to make a Tetris game using Processing but the Processing part won't work.
I get the following error :
java.lang.InstantiationException: InterfaceOutAndroid
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
charger : InterfaceOutAndroid.class cannot be instantiated.
I'm using Eclipse. Here is my class :
import java.util.Observable;
import java.util.Observer;
import processing.core.PApplet;
public class InterfaceOutAndroid extends PApplet implements Observer {
private static final long serialVersionUID = 6020713207736311342L;
Grille laGrille;
int[] couleurs = {color(255,0,0),color(0,255,0),color(0,0,255),color(255,255,0),
color(255,140,0),color(162,0,255),color(0,208,239)};
public InterfaceOutAndroid(Grille grille) {
laGrille = grille;
}
@Override
public void update(Observable arg0, Object arg1) {
laGrille = (Grille) arg0;
}
public void setup() {
size(200,360);
Jeu leJeu = new Jeu();
leJeu.initialiserInterfaceOutAndroid();
leJeu.initialiserInterfaceInClavier();
ObservateurJeu o = new ObservateurJeu(leJeu);
KeyboardListener2 kl = new KeyboardListener2();
MyTimer t = new MyTimer();
t.setPasDeTemps(800);
kl.addObserver(o);
t.addObserver(o);
new Thread(t).start();
new Thread(kl).start();
PApplet.main(new String[] {"--present","InterfaceOutAndroid"});
}
public void draw() {
for (int i = 0; i < laGrille.getLargeur(); i++) {
for (int j = 0; j < laGrille.getHauteur(); j++) {
fill(couleurs[laGrille.getCase(i,j).getCouleur()]);
stroke(255);
rect(i*20, j*20, 20, 20);
}
}
}
}
I don't understand what's wrong.
I did the following small test and it worked without any problem:
import processing.core.PApplet;
public class Main extends PApplet {
private static final long serialVersionUID = 4648172894076113183L;
public void setup() {
size(200,360);
for (int i=0;i<10;i++){
for (int j=0;j<18;j++){
alea = floor(random(couleurs.length));
fill(couleurs[alea]);
stroke(255);
rect(i*20,j*20,20,20);
}
}
}
int[] couleurs={color(0,0,0),color(255,0,0),color(0,255,0),color(0,0,255),color(255,255,0),color(255,140,0),color(162,0,255),color(0,208,239)};
private int alea;
public void draw() {
}
}
Could the issue come from the Observer pattern?
Thanks a lot for your help !
«Prev
Next »
Moderate user : mathilde.33
Forum