• 211lab12_S11
Skip to end of metadata
Go to start of metadata

Lab 12: Graphical User Interfaces (GUI's) in Java

For most of the relevant Information on how to build GUIs in Java, see the following reference:  Java GUI Programming Primer

The content below discusses material not explicitly covered in the above reference.

Few people code GUI's by hand these days--it's just too complicated.   Typically, one would use a "GUI builder" to drag-and-drop GUI components onto a design canvas, greatly simplifying and speeding up the GUI creation process.   But it is very helpful to know the basics of how to build a GUI by hand because one often needs to go in an manually tweak the GUI code even when using a sophisticated GUI builder tool.

Basic structure of a simple GUI application:

Some typical GUI initializations:

Set title and size of the frame:

Panels in main frame:

A Button with a listener on the control panel:

A Label and a TextField with a listener on the control panel:

 A text area with scroll bars in the center of the frame:

SerialVersionUID compiler warning:

A very common compiler warning to receive is the following for your frame class and other customized GUI components:

If you do, add the following field to the class:

For more information, see this web page .

  • No labels