Appendix A. Final Code Kitchen
Note
Finally, the complete version of the BeatBox!
It connects to a simple MusicServer so that you can send and receive beat patterns with other clients.
Final BeatBox client program
Most of this code is the same as the code from the Code Kitchens in the previous chapters, so we don’t annotate the whole thing again. The new parts include:
GUI: Two new components are added for the text area that displays incoming messages (actually a scrolling list) and the text field.
NETWORKING: Just like the SimpleChatClient in Chapter 17, the BeatBox now connects to the server and gets an input and output stream.
MULTITHREADED: Again, just like the SimpleChatClient, we start a “reader” job that keeps looking for incoming messages from the server. But instead of just text, the messages coming in include TWO objects: the String message and the serialized array (the thing that holds the state of all the checkboxes).
All the code is available at https://oreil.ly/hfJava_3e_examples.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access