Java™-based development framework for PalmOS™ devices (PDAs) Copyright© 2000 by Bernd R. Fix. All Rights Reserved. |
|
DynaWorks TutorialHow to write applications with the DynaWorks framework |
User widgets: Table Of Content |
|||||
DynaWorks custom widgets |
|||||
DynaWorks includes two new widgets that you can use
for your own applications. The first one is a replacement for the build-in
Slider control. The second control is named Tree
and is a tree control. You can find more controls in the User Contribution Section.
|
|||||
Creating your own user interface widget |
|||||
The following user interface elements that come with KVM can be used to setup the user
interface for a page:
You can create your own widget by implementing the UserWidget interface from the DynaPage framework. You have to implement all the methods of the interface:
All the event handlers of a user widget that process kjava level events (like handlePenMove()) can pass back an ActionEvent object that is passed to the event handler of the container page object. This approach is very helpful if you want to create a more 'abstract' behaviour of a UserWidget. Instead of dealing with low-level events the widget you can now handle events like VALUE_CHANGED or INVOKED that better fit into the 'application logic'.
|
|||||
Writing a custom slider control |
|||||
As an example of a custom widget we will create a new slider control.
Our new slider will be able to trigger VALUE_CHANGE events whenever
the user moves the marker. Of course this is just a 'quick-and-dirty' implementation with raw functionality; you will probably include more methods (like drawing ticks) or the like if you write your own slider. The only speed improvement is the use of an 'update()' method that is only redrawing the marker instead of the complete control.
Here's the implementation:
As you can see, there is no magic in writing your own custom user interface control with DynaWorks. Let's see how you would use the slider in your application:
|