Sorry if this seems too easy, I'm brand new to JavaFX, this is my first little application built with it.
I am trying to make a bare bone chat client. I use the JavaFX Scene builder to make the client user interface, and the controller class connected to FXML.
How can I make sure that the current text in the text area is sent to the server and the text area is deleted when I press the enter key, instead of using any send button?
EDIT: Here is the code that does not work:
public class FXMLDocumentController
{
@FXML private TextArea messageBox;
messageBox.setOnKeyPressed(new EventHandler<KeyEvent>()
{
@Override
public void handle(KeyEvent keyEvent)
{
if(keyEvent.getCode() == KeyCode.ENTER)
{
}
}
});
source
share