G4P: GEvent how to check for ENTERED [SOLVED]
in
Contributed Library Questions
•
7 months ago
I modified this code from one of the G4P examples:
- public void txf1_change1(GTextField tc, GEvent event) { //_CODE_:textfield2:640996:
switch(event) { - case ENTERED:
sentense=tc.getText();
System.out.println(sentense);
sentense="";
tc.setText("");
break;
default:
break;
}
}
This works great within my code where I have a text field and want its string contents printed every time I hit the enter key.
Since I am only checking for one thing I thought the case/switch approach was not needed so I tried
- if (event == ENTERED){
- sentense=tc.getText();
System.out.println(sentense);
sentense="";
tc.setText(""); - }
but it wouldn't understand ENTERED... Not sure why it can get it in CASE but not in IF?????
1