Help, something doesn't work
Hopefully, if you encounter any errors, you will find a quick solution here. The list will be updated.
- The Application seems stuck from beginning
- NullPointerException
- InvocationTargetException
- Element is created but does not show up on application
The application seems stuck from beginning
No errors, when you hit run everything looks okay but the gui does not react to clicking or moving the
mouse? Probably you forgot the void draw(){} method in the sketch. If you don't put it there
the sketch won't loop (general behavior in Processing). Or you have some blocking code in draw
that is stuck.
Oh yes, or you have some noLoop() called somewhere in your code.
NullPointerException
Okay, so that can have lots of reasons and many of them would not have to do with the library. In general, a
NullPointerException happens when you access an object (variable) but have not initialized it.
Look at the
line of code that's highlighted when the error occurs. If it is some piece of code that creates a new
instance of a Component from guiSET then maybe you forgot to create an instance of
Frame before(!). Code like this would create such an error:
void setup() {
// need to initialize Frame first
button = new Button();
}
And no you can't intialize Frame when declaring as global variable (passing this cannot work then).
Frame f = new Frame(this); //does not work
void setup() {
}
InvocationTargetException
Looks like you're trying to create an element as global variable. While you can have elements as global variables you cannot (for most components at least) initialize them there. What I mean is:
Button b = new Button(); // this will fail
void setup(){
f = new Frame(this);
b = new Button(); // here is where you should use "new"
}
Reasons for this are quite complex and include needing Frame to be intialized first. This might
not change in the near future.
Of course this error can have also different reasons I can't think of right now.
Element is created but does not show up on application
Sounds silly but maybe you forgot to add it to Frame or to another Container?
That's a common mistake. Or the position is outside the window. Or there is another element above hiding it.
