COP 2800 (Java Programming I) Project #6
GUI Text Encryption

 

Due: by the start of class on the date shown on the syllabus

Description:

Using the TxtCrypt application as an example, create a Java GUI stand-alone application that allows a user to encrypt any text as Pig Latin.  For example, the string "Java is very simple!" should be converted to the string "Avajay isway eryvay implesay!".  You may use either AWT or swing.

Requirements:

Write a stand-alone Java GUI application called TxtCrypt.  Use either AWT or swing.  This application should allow anyone to convert any text into Pig Latin.  Your application must provide a pair of TextArea (or JTextArea) components where the user can type in any text into the first, and see the encrypted results in the second.  The input text is called the plaintext, and the resulting Pig Latin is called the ciphertext.  You must provide the basic GUI and event handling.  This must include a button, which when pressed displays the ciphertext for the currently displayed plaintext.  (You may add additional GUI components as you see fit.)

I have provided class utils.PigLatin (view utils.PigLatin API), which is a class with a public static method called encrypt.  (See below for the download link.)  This method takes a String as an argument, and returns an encrypted, “Pig-Latin-ized” version of the argument as another String.  The method signature is:

    package utils;
    public class PigLatin
    {
        public static String encrypt ( String plainText )
        { ...
        }

        ...
    }

I have provided the source code for class utils.PigLatin for you amusement. 

You only need the utils.jar file (right-click this link to save), which should be put into the same directory as your Java class file(s).  (If you place your application into its own Jar file, both Jars should be in the same directory.) 

To compile your application, don't forget you will need util.PigLatin to be found on your CLASSPATH.  The simplest way to do that is to have your Java source file (say Proj6.java) and utils.jar in the same folder, say on your Desktop.  Then you can compile your program like this on Windows:

C:\Users\yourname\Desktop>javac -cp .;utils.jar Proj6.java

To be turned in:

Email to me your Java source file(s), by copy-and-paste (no attachments please!).

Send projects to .  Please use a subject such as “Java I Project 6 Submission” so I can tell which emails are submitted projects.  When you submit the project by email, the only files you should send are your Java source file(s) for this project.  Do not email any class files, utils.jar, or PigLatin.java

However, if your application uses any media files (for the “creative extras” part of the assignment), you can submit them as attachments.

Send project questions to .  Please use a subject such as "Java Text Crypt Project Questions" so I can tell which emails are questions about the project.

Please review Submitting Assignments and Project Grading Criteria from your class syllabus for further details.

Sample Output:

The model solution application TxtCrypt.jar is available for you to download and play with. 

Hints:

Don't worry too much about how the PigLatin class works.  Just assume it works and use it as is.  (If you have extra time and would like to know how it works, I'd be happy to explain during office hours.)

Both TextField and TextArea (and the swing equivalents) share a lot of common functionality.  Following best object-oriented design principles, both of these classes extend (inherit from) a common parent class.  When trying to find useful methods for TextArea, be sure to look at the inherited methods too!

You should naturally use your own name, not mine in the application credits.

It is quite easy to use multiple classes in an Applet.  If you want you can use PigLatin.class directly, or you can create and use a Jar file.  (Jar files are like “zip” files, that contain several .class files in a single compressed archive.)  In practice the most common deployment method is to use a jar file.

Part of your grade is based on your creative extras you put into the project.  For example, my model has a good color scheme, a “clear” button, and a little humor.  (Some say very little!)  Your application may contain pop-up help, a menubar, graphics, animation, sound, and so on.  For credit your creative extras must be your own, be useful and/or decorative in a text encryption application, and work correctly.  (Adding a calculator, or a button to change the colors, would not be considered useful in this case.  A joke wouldn't be considered creative since I used one already, but feel free to have one anyway if it's funny.)

Be aware that applets have security restrictions on what they can do.  No untrusted applet can access the clipboard (or other resources), or read or write files on the local system.  (It is possible to create a signed applet, which can then be granted extra privileges.  But this topic is not covered until the advanced Java course.)

You program should be easy to read and be well commented.  Don't forget to include your name at the top of each file.

Ask me for help if you get stuck!