CIT 591 Assignment 9: Text Translator
Notes
Fall 2008, David Matuszek
The screenshot shows an Edit menu. It should be a File menu.
Each of the four translators (Identity, etc.) is a class that
implements TranslatorInterface.
The Translator class is the main class. It should extend JFrame.
If you prefer, it can instead create and use a JFrame (but it's
usually easier just to extend JFrame).
The addTranslateItem(TranslatorInterface translator) method is just a GUI building method.
It doesn't do anything fancy--for example, it doesn't let the user add menu
items to a running program! All it does is:
ActionListener. Each
time you call addTranslateItem, it creates an new object of your ActionListener,
and saves the parameter translator in an instance
variable. When your ActionListener is used, it uses this instance variable
to get the name and description and to do the translation. To add yet another translator (class that implements TranslatorInterface)
to the program, all you should have to do is create a new translator of that
type, and add a call to addTranslateItem in your GUI building
method.
Here's what the "translate" listener does:
The program does only one kind of translation at a time. It does not do all four at once.
Here's the way translation should work.
The purpose of the Wrap Lines translator is to break annoyingly long lines. It should never join two lines.
For my translator,
JTextArea to hold the translator description. To make it fill
the area, I put it in the CENTER of a BorderLayout.JTextArea inside
a JScrollPane inside a JPanel. (You can find JScrollPane in
my SwingExamples.jar program
if you look hard enough.) I also used a TitledBorder, but
you don't have to get that fancy.