im a beginner java user so forgive me for my poor code! :)... i have a simple gui with a textarea and txtbox the textarea is used for output and the textbox is used for input... i also have a few other classes which need to take the input... unfortunatly this gui cannot have any buttons.... my problem is this. I have a method called getInput which looks like this!
private void getInput(KeyEvent keyEvent){
int keyCode = keyEvent.getKeyCode();
String keyText = KeyEvent.getKeyText(keyCode);
if(keyText.equals("Enter")){
userinput = input.getText().toString();
input.setText("");
}
}
and another method that is called by other classes
public String getInput(){
//getInput();
input.requestFocusInWindow();
getInput(keyEvent);
return userinput;
}
however when getInput is called by other classes it runs and returns an empty userinput which generates an error!....
So my question is how do i get the user to enter the information into the textbox and press enter before the getInput() finishes
i would be greatful for any help thanks :D