Home > Articles > Programming > Java

This chapter is from the book

This chapter is from the book

Summary

This chapter introduced the Swing tree control, one of two powerful data display components that you have at your disposal. After seeing the basic components of a tree, you learned how trees are created and how the user can manipulate them by expanding and collapsing nodes and making selections. You also saw how these actions are reflected in the tree itself and how they can be intercepted by applications and by custom components derived from the JTree class.

One of the more popular uses for a tree control is to display the content of a file system. A large portion of this chapter was devoted to creating a subclass of JTree that can show a file system in hierarchical form. The implementation of this control reveals much of the inner workings of the tree's data structures.

Finally, you saw several ways in which the tree's appearance can be customized to suit the needs of particular applications and discovered how to allow the user to edit the contents of a tree, while still making sure that only meaningful changes can be made.

  • + Share This
  • 🔖 Save To Your Account