I have searched for a long time for how to write a KeyEvent
to allow my Button clicks by ENTER key
. Note that I'm using JavaFX and FXML
files.
The problem is that when set in the onKeyTyped text field in the FXML file, the FXML Files doesn't accept it. It says Handle method not found
. It just accept ActionEvent
method so I have tried this code:
@FXML
private void key (KeyEvent evt) throws IOException{
if (evt.getCode() == KeyEvent.VK_ENTER){
String az = text1.getText();
//c.1
if(az.contains("1")){
String hh = text11.getText();
Socket socket = null;
InetSocketAddress isa = new InetSocketAddress (hh,80);
}
}
}
So please can anybody help me?