README.TXT - THIS FILE CONTAINS INSTALL AND TEST INSTRUCTIONS FOR THE TIMERBEAN JAVA BEAN. 25 AUGUST 2003 CSCI 315 ADVANCED JAVA PROGRAMMING (SELF-PACED WEB COURSE) LAB 2 JAVA BEANS Andrew Tree 520 E. California Ave. Ridgecrest, CA 93555 Andrew.Tree@navy.mil Business Phone: (760) 939-3646 INSTRUCTIONS FOR INSTALLING AND STARTING THE TIMERBEAN JAVA BEAN 1. Download the compressed TimerBean.zip jar file from my website at the following address: http://students.cs.byu.edu/~treea/CSCI315/TimerBean.html 2. Copy the zip file to your local directory space and rename the file extension from .zip to .jar. 3. To view the project description and ADT documentations go to the following web address. http://students.cs.byu.edu/~treea/CSCI315/TimerBean.html 4. To build an applet using the TimerBean bean in the Java BeanBox perform the following steps. [A graphical representation of the following steps can be found here:] http://students.cs.byu.edu/~treea/CSCI315/ScreenShots/Example.html ******************************** Quick description of components that will be used in my example to follow. In the example to follow you will be creating an Applet that controls the TimerBean java bean. The TimerBean is a timer that increments to a certain user specified value then "times out" (it stops). Once the timer has timed out an "alarm" goes off by changing the icon to display "Time Out" and also by sending a message to all registered listeners of the TimerBean. To control the TimerBean we will be using the following 3 buttons: "Start" will start the timer/clock going. The timer will increment once every second until the time out value is meet. "Stop" will stop the TimerBean from incrementing. "Reset" will reset the TimerBean timer back to zero. With these 3 buttons you will be able to use all of the built-in capabilities to manipulate the timer. Finally, to listen or to display the TimerBean's status the TimerBean will be sending update messages to a java bean called "ChangeReporter." Its only purpose is to receive messages from the Timer Bean and display it's status. ******************************** A. Make sure you have the Java SDK installed and available in your PATH variable. The TimerBean Java Bean was developed using jdk1.3.1_01 B. Start the BeanBox. C. Load the TimerBean Jar file: (1) Select the 'File' menu and then the 'LoadJar...' submenu (File->LoadJar...) (2) Then when the "Open Dialog" box appears navigate to the TimerBean project directory and open/import the "TimerBean.jar" file. D. As you can see the TimerBean component was loaded into the BeanBox ToolBox. In this example it is the last component in the ToolBox with a time clock for an icon. E. In the BeanBox lay out 3 "OurButton" components, 1 "TimerBean" component, and 1 "ChangeReporter" component. F. Connect the first button ("Start") to the TimerBean: (1) Select one of the 3 "OurButton" components. (2) Select the following subdirectory from the Edit menu (Edit->Events->action->actionPerformed). G. Connect the "OurButton" component to the "TimerBean" component. You will notice a red line running from the button component; connect the two components by clicking on the "TimerBean" component. H. After connecting the two components the following "EventTargetDialog" dialog box will appear. Select the "startTimer" option from the dialog box and press OK. I. Now that we have made the connection between our first button and the TimerBean lets label the button. (1) Make sure our start "OurButton" is selected. (2) In the "Properties" Dialog box change the "label" property to read "Start" and hit the Enter key. J. Repeat steps F-I for the "Stop" and "Reset" buttons. K. Now we are going to connect the TimerBean with the ChangeReporter component: (1) Select the TimerBean component. (2) Select the 'propertyChange' submenu from the 'Edit' menu (Edit->Events->propertyChange->propertyChange). L. Select the "ChangeReporter" component. (You will notice a red line extending from the "TimerBean" component to whatever component you want to connect it to) M. In the "EventTargetDialog" dialog box choose the "reportChanger" target method. N. Editing the TimerBean "Time Out time": (1) Select the TimerBean component. (2) Double click the 'Time Out time' property in the "Properties" dialog box. (3) The TimeOutEditor dialog box should appear. O. Using the combo boxes choose the hour, minute and second that you what to change the 'Time Out' time to then select "Done". P. Notice that the 'Time Out' time property has changed to your selected value. Q. Your new Applet is now ready to be tested and deployed. PROJECT COMPLEXITY ISSUES: (1) The TimerBean is identified by an icon in the bean builder tool (BeanBox). (2) The TimerBean uses an Custom Property Editor. The "timeout" variable is manipulated by a custom built editor dialog box. Selecting values in a series of combo boxes the user can define the time that they want the TimerBean to "Time Out". It also insures that the user always chooses a valid time. (3) The TimerBean uses "Method Descriptors". Using Method Descriptors allows the user only to see the important methods. All of the confusing methods that make up the TimerBean are hidden from the user. (4) The TimerBean uses "Bound Properties". Bound properties tell interested listeners that their value has changed. In this example the "status" property in the TimerBean is a bound property. When the status of the TimerBean changes, then the "ChangeReporter" bean is automatically notified and it displays the new TimerBean status.