Sample Run ~ TimerBean

 
SETTING UP THE TIMER BEAN
EDITING THE 'TIME OUT' TIME PROPERTY
SAMPLE VIEWS

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:

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.

SETTING UP THE TIMER BEAN

Step 1:    Start the BeanBox.

 

Step 2:    Load the TimerBean Jar file: 

(1) Select File->LoadJar...

(2) Then when the "Open Dialog" box appears navigate to the TimerBean project directory and open/import the "TimerBean.jar" file.

 

Result:    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.

 

Step 3:    In the BeanBox lay out 3 "OurButton" components, 1 "TimerBean" component, and 1 "ChangeReporter" component as seen below.

 

Step 4:     Connect the first button ("Start") to the TimerBean:

(1) Select the far left "OurButton" component.

(2) Select Edit->Events->action->actionPerformed.

 

Step 5:    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.

 

Step 6:    After connecting the two components the following "EventTargetDialog" dialog box will appear.  Select the "startTimer" option from the dialog box and press OK.

 

Step 7:    Now that we have made the connection between our first button and the TimerBean lets label the button.  

(1) Make sure the far left button is selected.

(2) In the "Properties" Dialog box change the "label" property to read "Start" and hit the Enter key.

 

Step 8:    Repeat steps 4-7 for the "Stop" and "Reset" buttons.

 

Step 9:    Now we are going to connect the TimerBean with the ChangeReporter component.

(1) Select the TimerBean component.

(2) Select Edit->Events->propertyChange->propertyChange

 

Step 10:    Select the "ChangeReporter" component.  (You will notice a red line extending from the "TimerBean" component to whatever component you want to connect it to)

 

Step 11:    In the "EventTargetDialog" dialog box choose the "reportChange" target method.

 

EDITING THE TIME OUT TIME PROPERTY

Step 12:    Editing the TimerBean "Time Out time".

(1) Select the TimerBean compoent.

(2) Double click the 'Time Out time' property in the "Properties" dialog box.

(3) The TimeOutEditor dialog box should appear.

 

Step 13:    Using the combo boxes choose the hour, minute and second that you what to change the 'Time Out' time to then select "Done".

 

Step 14:    Notice that the 'Time Out' time property has changed to your selected value.

 

SAMPLE VIEWS

Sample View 1:    View of the TimerBean running.

 

Sample View 2:    View of the TimerBean timed out.