[G4P] Check state of options or checkboxes
in
Contributed Library Questions
•
4 months ago
First of all:
Thanks for that awesome library and the builder tool. Really helped me to grab a foothold in the whole processing business. :)
The only thing i can't get working are the checkboxes and option groups.
To explain what my problem is, i made a simple example program with the GUI builder:
Main Tab:
- // Need G4P library
- import g4p_controls.*;
- int bgcolor=100;
- public void setup(){
- size(480, 320, JAVA2D);
- createGUI();
- customGUI();
- // Place your setup code here
- }
- public void draw(){
- background(bgcolour);
- }
- // Use this method to add additional statements
- // to customise the GUI controls
- public void customGUI(){
- }
gui Tab:
- public void checkbox1_select(GCheckbox source, GEvent event) { //_CODE_:checkbox1:537084:
- println("checkbox1 - GCheckbox event occured " + System.currentTimeMillis()%10000000 );
- if (checkbox1 == true) {
- bgcolor=1;
- }
- else bgcolor = 230;
- } //_CODE_:checkbox1:537084:
- // Create all the GUI controls.
- // autogenerated do not edit
- public void createGUI(){
- G4P.messagesEnabled(false);
- G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
- G4P.setCursor(ARROW);
- if(frame != null)
- frame.setTitle("Sketch Window");
- checkbox1 = new GCheckbox(this, 176, 147, 120, 20);
- checkbox1.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
- checkbox1.setText("checkbox text");
- checkbox1.setOpaque(false);
- checkbox1.addEventHandler(this, "checkbox1_select");
- }
- // Variable declarations
- // autogenerated do not edit
- GCheckbox checkbox1;
Well, it didn't work. I just want to read the state of the checkbox (or option). I got the Textfield working with getText() and setText(), getValue() didn't work either.
Any advice here?
Thanks in advance!
1