Summary
This tutorial introduced you to Swing and the concepts you need to know to create a basic, functional user interface. After completing this tutorial, you should have accomplished several things:
- You should be familiar with the Swing components. You should be able to recognize the components when you see them on the screen and apply them in your own applications by using their basic functions. In addition, you should have a general understanding of when you should use the components (for example, when to use a JCheckBox vs. when to use a JRadioButton).
- You learned how to lay out these components on the screen with layout managers. Layout managers have existed since Java first came out, and unfortunately, the most powerful layout manager is also the most difficult to use. However, visual editors (such as the one found in Eclipse) make the layout process incredibly easy by creating all the layout code automatically.
- You learned about the event model, mainly how Swing uses the event/listener model in all of its components to allow one component to accept user interaction and pass this interaction on to other classes. These other classes register for events from the component and take appropriate action when they receive events. The event/listener model is used throughout Swing, and you should learn it in depth to better work with every Swing component.
- You learned about data models and how they fit into the MVC architecture in Swing. Models allow components to display data without knowing anything about the data itself. They also let you reuse models, allowing multiple components that display similar data to use the same model, eliminating the need to create an original model for each instance of the component. In large-scale applications, models serve as the "translation" between server-side data objects and client-side Swing components.
It's important and vital to understand that this tutorial is not all-encompassing. It's not even meant to cover all the basics of Swing. There's just far too much to squeeze into this tutorial to give beginners a thorough introduction to Swing. I've hopefully pointed out the crucial elements, including the most commonly used components and their most commonly used functions. You should be aware that probably about twice as many components exist in Swing, and I encourage you to look through Swing documentation to cover the ones I missed. Also, I've barely touched upon the functions of most of the components; each Swing component has dozens, even up to a hundred, functions you can potentially use.
But I don't want to rain on your parade. By finishing this tutorial you've learned quite enough to build a majority of your Swing applications, and the knowledge gained from this tutorial serves as a solid foundation if you explore the other functionalities and components Swing offers.
As you know by now, this tutorial has a companion called "Intermediate Swing," which will build upon the knowledge you've gained in this introduction with an examination the more difficult concepts you need to understand to make your application more polished and powerful. These concepts include:
- More advanced JTable features including the table properties, more sophisticated TableModel management, the TableRenderer to change the appearance of the JTable, and how to sort the table columns.
- Threading and how it fits into Swing. Because users cannot accept an interface that locks up when it hits the database, Swing must use separate threads for longer operations.
- How to create custom components. If you feel limited by what Swing offers you now, I'll show you how to create components that might look or behave differently than the ones built into Swing.
- Custom look-and-feels. I will discuss how to completely change the look and feel of an application through two methods: one creates a new custom UI look-and-feel and the other uses Synth, a skinnable look-and-feel.


