CSc 4110/6110 Embedded Systems
Lab Experiment #4
Spring 2008
Instructor: Dr. Michael Weeks
Due date: April 14, in class
Using AWT with Java - Remote-control simulation
Java's Abstract Window Toolkit (AWT) provides a way to create
graphical user interfaces (GUIs). These programs act in a different
way than most programs, since they set up an interface and execute
code based on interaction with the user. The programs stay active
even after the main method completes.
Window components can have listeners to handle user interaction,
by executing code based on, say, the user pressing a button.
In this lab, you will simulate a remote controller for a TV set-top box.
The controller should have buttons for 0-9, stop, play, pause, fast-forward,
rewind.
See the following book and read chapter 12:
Kim King, Java Programming From The Beginning, Norton, 2000.
Your task is to write a Java program using the AWT:
- Show a keypad with space at the top for up to 20 characters
of text. Channels may be three or four digits. As the user
presses the number buttons, the digits entered should appear at the
top.
- If the user enters conflicting input, the top space should show
an error message. For example, if the user presses "stop" twice,
your program should indicate that stop was already pressed.
- Keep track of the time. Approximately two seconds after entering
the number, the system should change to that channel. So the
sequence "1" (half second pause) "2" (400 millisecond pause)
"3" (2 second pause) "4" (half second pause) "5" (2 second pause)
should be interpreted as change the channel to "123", then
change the channel to "45".
- Check for a valid channel. Assume that the user has
Dish network's top 100 channels.
If an entered channel number is invalid (such as channel 45 above),
inform the user, and go back to the previous channel.
- Simulate doing each operation as a command is given. For example,
the "play" button is a complete command by itself, so pressing
this button should generate a response by your program.
When your code works, port it to the iPAQ.
To make your program work with the Java Virtual Machine on the iPAQs,
you may have to use an "older" compiler. You can do this with the command:
javac
-target 1.1
which compiles the Java code for version 1.1.
This should also work for version 1.3:
javac
-target 1.3 -source 1.3
Write-up what you did IN YOUR OWN WORDS. Do not simply re-word the directions,
but explain what is going on. Avoid listing steps. Use outside sources
as appropriate, and be certain to cite your sources.
This lab should be done individually. Turn in one report per person.
Questions:
- How is programming a GUI different from "standard" programming?
- How can you keep the "main" method running, to occasionally check
for changes and make updates?
- How is your program different on the iPAQ than it was on the PC?
- How large is the byte code of your program?
- How does AWT compare to Swing? Research this, describe it,
and be sure to cite sources in your answer. (This should be at least
2 pages.) As stated in class, Wikipedia is not a valid source for
research work. Do not use Wikipedia for this assignment.
You are advised not to even look at webpages for your answer.
Instead, find books and articles in professional publications.