Authorizing the client

Up until this point, everything has assumed that the desktop is already connected to the phone. We have enough pieces in place now that we can talk about that in a meaningful manner.

In the application's main Menu, we have two MenuItems: Connect to Phone and Disconnect from Phone. The Connect to Phone handler looks as follows:

    @FXML 
    protected void connectToPhone(ActionEvent event) { 
      ConnectToPhoneController.showAndWait(); 
      if (!preferences.getToken().isEmpty()) { 
        refreshAndListen(); 
      } 
    } 

We're going to use the now-familiar showAndWait() pattern to display a modal dialog, and to get the response using the new ConnectToPhoneController. The user interface is very simple, and is shown in this screenshot:

When the user ...

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.