I am trying to get input value from 3checkbox in one array, upto 5 or more array here is my code. I entre value in the textbox to genertate the checkbox arrays.
// Need G4P library import g4p_controls.*;
public void setup(){ size(480, 320, JAVA2D); createGUI(); customGUI(); // Place your setup code here
}
public void draw(){ background(230);
}
// Use this method to add additional statements // to customise the GUI controls public void customGUI(){
}
public void textfield1_change1(GTextField source, GEvent event) { //CODE:txtno:852228: // println("txtno - GTextField >> GEvent." + event + " @ " + millis());
// println(txtno.getText()); } //CODE:txtno:852228:
public void button1_click1(GButton source, GEvent event) { //CODE:btnSubmit:452090: //println("btnSubmit - GButton >> GEvent." + event + " @ " + millis()); //Integer.parseInt(
String actant = txtno.getText(); if(actant.isEmpty()){ println("increase the number of acctant"); } else{ println(txtno.getText()); int i = Integer.parseInt(txtno.getText()); for(int x=1; x<=i; x++){ //Actant number to display
G4P.messagesEnabled(false);
G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME); G4P.setCursor(ARROW); //surface.setTitle("Actant Input");
for(int j=1; j<=3; j++){ int a = 100 * j; int b= 20 * x;
//for creating Label for actant.
if(j==1){
lblTitle = new GLabel(this, -95+a, 30 + b, 85, 20);
lblTitle.setText("Actant No: "+ x + ".");
lblTitle.setOpaque(false);
}
//For Creating checkbox
chkA1 = new GCheckbox(this, 5+a, 30 + b, 85, 20);
chkA1.setTextAlign(GAlign.LEFT, GAlign.MIDDLE);
if(j==1){
chkA1.setText("Heat");
}
else if(j==2){
chkA1.setText("Noice");
}
else{
chkA1.setText("Smell");
}
chkA1.setOpaque(false);
chkA1.addEventHandler(this, "chka1");
}
}
}
} //CODE:btnSubmit:452090:
// Create all the GUI controls. // autogenerated do not edit public void createGUI(){ G4P.messagesEnabled(false); G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME); G4P.setCursor(ARROW); surface.setTitle("Sketch Window"); lblActant = new GLabel(this, 5, 5, 95, 22); lblActant.setText("Actant Number"); lblActant.setTextBold(); lblActant.setOpaque(false); txtno = new GTextField(this, 104, 4, 43, 30, G4P.SCROLLBARS_NONE); txtno.setOpaque(true); txtno.addEventHandler(this, "textfield1_change1"); btnSubmit = new GButton(this, 158, 8, 80, 30); btnSubmit.setText("Submit"); btnSubmit.addEventHandler(this, "button1_click1");
}
// Variable declarations // autogenerated do not edit GLabel lblActant; GTextField txtno; GButton btnSubmit; GLabel lblTitle;
//Creating CheckBox GCheckbox chkA1;
// Create all the GUI controls. // autogenerated do not edit public void chkBox(){ //G4P.messagesEnabled(false); //G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME); //G4P.setCursor(ARROW); //surface.setTitle("Sketch Window"); //for(int j=1; j<=3; j++){ // int a = 100 * j; // chkA1 = new GCheckbox(this, 5, 40, 85, 20);
//chkA1.setTextAlign(GAlign.LEFT, GAlign.MIDDLE); //chkA1.setText("1"); //chkA1.setOpaque(false); //chkA1.addEventHandler(this, "chka1"); } //}
thank you in advance.