controlP5 button class issue
in
Contributed Library Questions
•
1 year ago
Hi guys,
I'm having trouble with my custom class. I get the following error:
- 22-Mar-2012 14:31:18 controlP5.ControlBroadcaster printMethodError
- SEVERE: An error occured while forwarding a Controller value
- to a method in your program. Please check your code for any
- possible errors that might occur in this method .
- e.g. check for casting errors, possible nullpointers, array overflows ... .
- method: biology
- exception: java.lang.reflect.InvocationTargetException
It happens when I click the button. It didn't happen when the button weren't created using the class. I thought it was maybe because tabs and buttons had the same name but changing that didn't fix it.
Button code:
- /*
- ** biology button handler
- */
- public void biology(){
- // debugging
- println("biology");
- baseSet("bio");
- cp5.tab("biology").setActive(true);
- }
- /*
- ** chemistry button handler
- */
- public void chemistry(){
- baseSet("chem");
- cp5.tab("chemistry").setActive(true);;
- }
- /*
- ** physics button handler
- */
- public void physics(){
- baseSet("phys");
- cp5.tab("physics").setActive(true);
- }
Class code:
- class myButton{
- String buttonName,name;
- int alph,x,y,width,height,colour,topMargin;
- ControlFont font;
- Button button;
- myButton(Button _button, String _name, int _alph, int _x, int _y, int _width, int _height, int _colour, int _topMargin, ControlFont _font){
- button = _button;
- name = _name;
- alph = _alph;
- x = _x;
- y = _y;
- width = _width;
- height = _height;
- colour = _colour;
- topMargin = _topMargin;
- font = _font;
- }
- void display(){
- button = cp5.addButton(name,0,x,y,width,height);
- button.captionLabel().setControlFont(font);
- button.captionLabel().style().marginTop = topMargin;
- button.setColorBackground(colour);
- button.setColorForeground(colour);
- }
- }
Any ideas?
1