We'll start with the interface code we developed last time. To this we'll add listeners to enable reading, replying, and posting functionality. We're going to reuse a networking class from a previous installment to implement the networking to the Forum server, which we'll also reuse from a previous installment. In response to a reader suggestion, we're going to add a JSplitPane between the tree on the left and the tabbed display area on the right. The JTree is the central widget in the Swing Forum.
Users interact with the tree to select threads and the articles they contain.
The JTree displays data from the DefaultTreeModel, which is composed of DefaultMutableTreeNodes. The JTree itself handles the tasks of displaying the tree structure and handling user events. The tree model is made up of tree nodes, each of which is an instance of DefaultMutableTreeNode . To allow the user to manipulate the threads and articles on the server, we need to define user actions on the tree for refreshing and navigating. Communications and networking Because the server is the reference copy of articles and threads, we need to find some way to access the server and display its contents in the tree.