controlP5 tab class
in
Contributed Library Questions
•
1 year ago
Hi guys,
I'm trying to make a class to create controlP5 tabs however the way I have done it throws a null pointer exception. It's on line 39 that the exception occurs. Anyone have any ideas on what I'm doing wrong?
- import controlP5.*;
- ControlP5 controlP5;
- ControlFont font;
- MyTab[] tabs = new MyTab[4];
- void setup()
- {
- PFont pfont = createFont("Bebas-48.vlw", 40, true);
- font = new ControlFont(pfont);
- String name = "home";
- String label = "welcome";
- size(300, 300);
- tabs[0] = new MyTab(name, label, 0, width, 40, font, 40, 0xFFFF0000);
- tabs[0].display();
- }
- class MyTab
- {
- String name, label;
- int id, w, h, margin, colour;
- ControlFont font;
- MyTab(String _name, String _label, int _id, int _w, int _h, ControlFont _font, int _margin, int _colour)
- {
- name = _name;
- label = _label;
- id = _id;
- w = _w;
- h = _h;
- font = _font;
- margin = _margin;
- colour = _colour;
- }
- void display()
- {
- controlP5.tab(name).setLabel(label);
- controlP5.tab(name).activateEvent(true);
- controlP5.tab(name).setId(id);
- controlP5.tab(name).setWidth(w);
- controlP5.tab(name).setHeight(h);
- controlP5.tab(name).captionLabel().setControlFont(font);
- controlP5.tab(name).captionLabel().style().marginLeft = margin;
- controlP5.tab(name).setColorActive(colour);
- }
- }
2