Java Programmer's Guide and Reference
This section provides a step-by-step example to show you how to create a
desktop softphone with Dial, Answer, and Hangup buttons using telephony beans
and a visual builder.
The example includes IBM VisualAge(TM) for Java illustrations, but you can
use any visual builder that supports JavaBeans (the connections you make and
the properties you set are similar regardless of the visual application
builder tool you use).
- Place a CPLineResource, which represents a single telephone
line, near the bottom of your visual builder work area.
- Specify the CPLineResource properties, such as
address, terminal, and user
information. (After the application is created, you can change
these parameters while the application is running.)
This step is illustrated in Figure 7.
Figure 7. Add a CPLineResource

- Connect the start() event of the application to the
start() method of the CPLineResource.
- If you are using the VisualAge for Java visual builder, you must make an
"offscreen" connection from the nonvisual portion of the workspace to the
CPLineResource. Click Show Expert Features to
expose the start() event. Connect this to the
start() method of CPLineResource.
This step is illustrated in Figure 8.
Figure 8. Start the CPLineResource

- Add the MakeCall, AnswerCall, and
DisconnectCall Action beans to the visual builder work area.
(These Action beans represent the Dial, Answer, and Hangup button
functions.)
- Associate the Action beans with the CPLineResource bean by doing the
following:
- Connect the lineResourceDataInitialized event of the
CPLineResource bean to the associate method of the Action
bean.
- Choose the associate method that accepts the
LineResourceDataEvent class as a parameter. VisualAge for Java users
will then have to double-click on the connection and check the Pass Event
Data check box in order to pass the LineResourceDataEvent in as a
parameter. Doing this will change the connection from a dotted line to
a solid line, indicating that the parameter is being passed in.
This step is illustrated in Figure 9.
Figure 9. Add the Telephony Action beans

- Add the Dial, Answer, and Hangup buttons
- Add a Number entry field
- Add the title of the application
This step is illustrated in Figure 10.
Figure 10. Add visible controls

- Connect the actionPerformed event from each button (Dial,
Answer, and Hangup) to the action() method of the corresponding
button's invisible bean. This enables the action to be performed
whenever the user clicks the button.
- Connect the textValueChanged event of the entry field to the
destination property of the MakeCall bean.
- Connect the text property of the entry field to the
value property of the connection. This ensures that whatever
the user types into the entry field will also be set in the
destination property of the bean.
This step is illustrated in Figure 11.
Figure 11. Connect visible controls to model

- Connect the MakeCall bean's actionAdvancedEnabled event to
the Dial button's setEnabled(boolean enableFlag)
method. (In this case, enable the button, edit the connection, and set
the parameter to true.)
- Connect the MakeCall bean's actionEnabled event to the
Dial button's setEnabled(boolean enableFlag)
method. (In this case, you want to enable the button; edit the
connection and set the parameter to true.)
- Connect the MakeCall bean's actionDisabled event to the
Dial button's setEnabled(boolean enableFlag)
method. (In this case, you want to disable the button; edit the
connection and set the parameter to false.)
- Connect the MakeCall bean's actionPermanentDisabled event
to the Dial button's setEnabled(boolean enableFlag)
method. (In this case, you want to disable the button; edit the
connection and set the parameter to false.)
- Connect the AnswerCall bean to the Answer button and connect
the DisconnectCall bean to the Hangup button by following the
procedure for the MakeCall bean.
Figure 12 illustrates the completed application. Generate the
code using your visual builder and test your application.
Figure 12. Compile the code and test your application

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]