O'Reilly logo

Java 9 Programming Blueprints by Jason Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending messages

Now that we can see the conversations that we've been having, we need to add the ability to take part in those conversations--to send new text messages. We'll start on the client. We've actually already seen the handler for the New Message button assigned. It is as follows:

    newMessageBtn.setOnAction(event -> sendNewMessage()); 

What we need to do now is to look at this sendNewMessage() method itself:

 private void sendNewMessage() { Optional<String> result = SendMessageDialogController .showAndWait(conversation.get()); if (result.isPresent()) { Conversation conv = conversation.get(); Message message = new Message(); message.setThreadId(conv.getThreadId()); message.setAddress(conv.getParticipant()); message.setBody(result.get()); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required