Button disabled without telling it to be
in
Contributed Library Questions
•
4 months ago
Hello,
I am creating a GUI to test machine equipment. The problem I need help with is when I click button 1, it disables button 2. Is there something I am missing? Thank you for your help!
- /* =========================================================
- * ==== 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 button1_Click1(GButton button) { //_CODE_:button1:761563:
- println("button1 - GButton event occured " + System.currentTimeMillis()%10000000 );
- while(currentTime < runTime && stop == 0){
- while (port.available() > 0) { //as long as there is data coming from serial port, read it and store it
- serial = port.readStringUntil(end);
- if (serial != null) { //if the string is not empty, print the following
- currentTime = millis();
- if(currentTime - timeold >= interval){
- String[] a = split(serial, ','); //a new array (called 'a') that stores values into separate cells (separated by commas specified in your Arduino program)
- print(timeold);
- print(" ");
- print(a[0]);
- print(a[1]);
- print(a[2]);
- //send data to .csv file
- output.print(timeold); //print time
- output.print(",");
- output.print(a[0]); //print temp1
- output.print(",");
- output.print(a[1]); //print temp2
- output.print(",");
- output.print(a[2]); //print RPM
- timeold = millis();
- }
- }
- }
- }
- output.flush(); // Writes the remaining data to the file
- output.close(); // Finishes the file
- exit(); // Stops the program
- } //_CODE_:button1:761563:
- void combo1_Click1(GCombo combo) { //_CODE_:combo1:518103:
- println("combo1 - GCombo event occured " + System.currentTimeMillis()%10000000 );
- time_entered = combo1.getText();
- runTime = Float.parseFloat(time_entered);
- runTime = runTime * 3600000.0;
- } //_CODE_:combo1:518103:
- void button2_Click1(GButton button) { //_CODE_:button2:557094:
- println("button2 - GButton event occured " + System.currentTimeMillis()%10000000 );
- stop = 1;
- output.flush(); // Writes the remaining data to the file
- output.close(); // Finishes the file
- exit(); // Stops the program
- } //_CODE_:button2:557094:
- // Create all the GUI controls.
- // autogenerated do not edit
- void createGUI(){
- G4P.setColorScheme(this, GCScheme.BLUE_SCHEME);
- G4P.messagesEnabled(false);
- button1 = new GButton(this, "START", 79, 340, 80, 30);
- button1.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
- button1.addEventHandler(this, "button1_Click1");
- combo1 = new GCombo(this, loadStrings("list_518103"), 10, 62, 137, 80);
- combo1.setSelected(0);
- combo1.addEventHandler(this, "combo1_Click1");
- button2 = new GButton(this, "STOP", 356, 339, 80, 30);
- button2.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
- button2.addEventHandler(this, "button2_Click1");
- }
- // Variable declarations
- // autogenerated do not edit
- GButton button1;
- GCombo combo1;
- GButton button2;
1