University of Cincinnati logo and link  
Graphical User Interface (GUI) in Java
 
  UC ingot 
In Java, we use Swing to create GUIs.  But what is a GUI?  What is a fat client, and what is a thin client?  What are advantages and disadvantages of each?

We've already seen several Swing-based applications.  Can you think of some examples?  But Swing is not limited to programs invoked from your hard drive.  You can use Java Web Start, as our friend at Argo UML did, to manage fat client deployment and updating.  As a matter of fact, if you do create any Swing programs, I strongly urge you to consider using Web Start to manage deployment and updates.  Also, in some instances, you can use Swing to create applets, or programs that run in the browser.

What is Swing?  What does it look like and what can it do?  You can take an easy look at an advanced example.  Search the hard drive of a Java-installed computer for SwingSet2.jar.  I found mine under [JAVA-HOME]\demo\jfc\SwingSet2\.  When you have located the file, double click it to run it.  Select the tabs and try out the GUI components.

In the old days, we'd mix our GUI, data, and logic all in one.  Some software still lets you do this.  But Swing is based on the Model View Controller pattern.  What advantages does this have?

When we think about our GUI design, we must put very serious thought into the layout of the components.  This is more complicated than it may sound.  A GUI may look great on your computer, but consider the size of your monitor and the resolution of your screen.  How will it look on a different size monitor, perhaps with different resolution?  How will it look on a Palm device?  How do you make it flexible based on the end user's environment?  To answer these questions, we need to master layout managers.  It may look challenging on the surface, but trust me, it is worthwhile to learn.

Once we understand what Swing is, how we can use it, and how to effectively utilize layout managers, we can take a look at Swing components.  We'll generally start with a class that extends JFrame, add our JPanels and Swing components to the JFrame child, and then we're ready to implement our GUI interface.