Using the Swing GUI framework
With the GUI library chosen, we can now decide what classes this application will need and how they will be packaged. Here is the finished project layout:
Figure 13.5 – The Swing project layout
The source code on GitHub is extremely commented, and I encourage you to download it while reading this. Let us begin by looking at the basic components and controls of a Swing application. We begin with JFrame
.
JFrame
Every Swing application needs a main or top-level container. There are four classes for this purpose, but one is now deprecated for removal. They are JFrame
, JDialog
, JWindow
, and the deprecated JApplet
. The JWindow
class is ideal for splash screens, as they have no decorations, such as a border, title bar, or window controls. You commonly use JDialog
as part of an application to interact with a user over details you do not want in the top-level container you are using. It can also be used for simple applications...