Hi,
Can you help me? I am making a math program to help my son. I would like to be able to use radio buttons to represent numbers and then have the result of his choices appear in a text field. I am using g4p gui tool but am open to other libraries if you recommend. Thank you muchly.
main code
- // Need G4P library
- import guicomponents.*;
- void setup(){
- size(480, 320);
- createGUI();
- customGUI();
- // Place your setup code here
- }
- void draw(){
- background(200,220,200);
- }
- // Use this method to add additional statements
- // to customise the GUI controls
- void customGUI(){
- }
gui code
- /* =========================================================
- * ==== WARNING ===
- * =========================================================
- * The code in this tab has been generated from the GUI form
- * designer and care should be taken when editing this file.
- * Only add/edit code inside the event handlers i.e. only
- * use lines between the matching comment tags. e.g.
- void myBtnEvents(GButton button) { //_CODE_:button1:12356:
- // It is safe to enter your event code here
- } //_CODE_:button1:12356:
- * Do not rename this tab!
- * =========================================================
- */
- void option1_Click1(GOption opt_selected, GOption opt_deselected) { //_CODE_:one:233963:
- println("option1 - GOption event occured " + System.currentTimeMillis()000000 );
- GTextField.result=2;
- } //_CODE_:one:233963:
- void option2_Click1(GOption opt_selected, GOption opt_deselected) { //_CODE_:two:593628:
- println("option2 - GOption event occured " + System.currentTimeMillis()000000 );
- } //_CODE_:two:593628:
- void option3_Click1(GOption opt_selected, GOption opt_deselected) { //_CODE_:three:842041:
- println("option3 - GOption event occured " + System.currentTimeMillis()000000 );
- } //_CODE_:three:842041:
- void option4_Click1(GOption opt_selected, GOption opt_deselected) { //_CODE_:four:648498:
- println("option4 - GOption event occured " + System.currentTimeMillis()000000 );
- } //_CODE_:four:648498:
- void textfield1_Enter1(GTextField textfield) { //_CODE_:result:239776:
- println("textfield1 - GTextField event occured " + System.currentTimeMillis()000000 );
- } //_CODE_:result:239776:
- // Create all the GUI controls.
- // autogenerated do not edit
- void createGUI(){
- G4P.setColorScheme(this, GCScheme.BLUE_SCHEME);
- G4P.messagesEnabled(false);
- optGroup1 = new GOptionGroup();
- one = new GOption(this, "1", 13, 74, 90);
- optGroup1.addOption(one);
- one.setSelected(true);
- one.addEventHandler(this, "option1_Click1");
- two = new GOption(this, "2", 13, 112, 90);
- optGroup1.addOption(two);
- two.addEventHandler(this, "option2_Click1");
- optGroup2 = new GOptionGroup();
- three = new GOption(this, "3", 141, 73, 90);
- optGroup2.addOption(three);
- three.setSelected(true);
- three.addEventHandler(this, "option3_Click1");
- four = new GOption(this, "4", 140, 114, 90);
- optGroup2.addOption(four);
- four.addEventHandler(this, "option4_Click1");
- result = new GTextField(this, "result", 269, 90, 80, 20, false);
- result.addEventHandler(this, "textfield1_Enter1");
- }
- // Variable declarations
- // autogenerated do not edit
- GOptionGroup optGroup1;
- GOption one;
- GOption two;
- GOptionGroup optGroup2;
- GOption three;
- GOption four;
- GTextField result;
1