![]() |
Objectives: |
Students will:
|
Background: |
GUI or graphical user interfaces are the way most of us communicate with computer programs. Tools such as Eclipse and JGrasp have a graphical interface with which we interact. But GUI applications are code, just like all applications, and using the rich component libraries of the Java swing class and awt, you can begin to build your own graphical front ends. Listeners are application software that "listen" for the actions of some component of the system, like the user pressing a key. These events can trigger specific code to run when the specified action is carried out. We will be working with an ActionListener in this application. ActionListener is in interface in Java and specifies that the actionPerformed event be implemented. Once a class implements the ActionListener, it can be added to GUI components to carry out the intended action. |
New Terms: |
ActionListener GUI Components |
Materials: |
Clicker.java, ClickerDriver.java ExpressionDriver.java ExpressionsGUI.java, ExpressionParser.class |
Acknowledgment: |
Clicker is a variant of a Tutorial in the Java Tutorials library (http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html) |
First an orientation to some of the GUI terms. A Frame object is a window with a border and a body. In this lab, we will use a specialization of Frame which we will call Clicker. A Clicker objectt contains in its body a Button object and a TextField object.
So now let's look at how such a Frame is built in Java code.
Updated 03/27/2014 (nlh)