Java User Interfaces
The goal of today's lab is to practice implementing Graphical User
Interfaces in Java.
Resources
Note that the Java GUI framework makes extensive use of inheritance.
This can make reading the documentation difficult because a majority of
methods only appear in the "Methods inherited from ..." section of the
JavaDocs.
Part 1: Decoder Ring
The file DecoderRing.java includes
utility methods for encrypting and decrypting messages using a simple
substitution cipher.
Your task today is to create a GUI application that makes it easy for
a user to encrypt and decrypt messages using the methods provided
by DecoderRing.java
. You are free to
design your application however you want, within the following
constraints:
- Your new class must be named DecoderGUI.
- All input and output must be handled within a single window
— your application should not interact with the user by
popping up JOptionPanes.
- All text areas and buttons must be labeled.
- Your application must contain separate text fields for the
message to encode/decode and the result of encoding/decoding. The
result field must be read-only.
- The GUI must provide the user with a way to select an integer
key value.
- Use should not use a GUI-Building tool
like Netbeans
or WindowBuilder.
Those tools are very useful, but you need to be able to understand the
code they generate.
- You do NOT need to worry about error handling. For example, you
may assume that the user will enter a valid integer for the key.
Part 2: Decoder Ring Layout (If Time)
You now have a simple graphical application for encoding and decoding
secret messages. You probably found it difficult to create an
attractive GUI without any mechanism to accurately specify the
locations of components. Even if you did manage to create a
reasonable looking GUI using the default FlowLayout
manager, it won't resize very gracefully.
The next step is to improve your decoder ring application so that
it makes appropriate use of layout managers. The appearance of your
application is up to you, but it should satisfy the following
requirements:
- Use at least one layout manager other than the default
FlowLayout
.
- Use multiple panels to organize your components.
- Layout should be relatively robust to resizing.
Submitting
Submit your completed DecoderGUI.java through Web-CAT.