TextArea and ScrollableTextArea


 

November 1999

 

I have had numerous requests for an implementation of a multi-line text input control which does not depend on the mWaba toolkit library. I have therefore rewritten and somewhat stripped down the original version of my TextArea to provide a new one which can be used (along with a few support classes) with Waba alone. It is designed for Waba Beta 9 and will probably not work with older versions. It works fine under Java and WinCE but I am unable to test it on a PalmOS device. If someone detects any problems when using it under PalmOS please let me know at: michael_brereton@hotmail.com


I have provided all the source code for the control and its support classes and the JavaDoc generated API. Feel free to use it as you want, commercial or otherwise, just remember to cite myself as the original author in any redistribution of the code.


The source code, API and this page is in this Zip file: TextArea.zip(68K)
It also contains a make file to generate the wrp/pbd files. However you can also download these files, already made, along with the class files, in this zip file: TextAreaClasses.zip(61K)


 

TextArea allows multi-line text input. It features:

 

Overall it provides most of the features you would need from such a control. The new-line character ‘\n’, is used to separate lines within the display.

 

ScrollableTextArea inherits from TextArea and implements the ScrollClient interface which allows it to be placed in a ScrollableContainer. The ScrollableContainer provides horizontal and/or vertical scroll bars to any control which implements the ScrollClient interface. Unlike the ScrollablePanel in the mWaba toolkit, this ScrollableContainer does not support appearing and disappearing scroll bars so the scroll bars will always be visible.

 

To use the TextArea

Using the control is fairly simple, even without the API:

  1. Create the TextArea.
  2. Assign a font to the font member if you want to change the font.
  3. Add it to your container and set its size using setRect().
  4. Use setText() and getText() to set and get the text of the control.

 

And that’s it. There are a few member variables that you can change to alter the behavior of the control. Check the source code or API to see them.

 

The classes you would need to use the TextArea are: TextArea. AdvControl, Point, DragContext, ImageBuffer, IScroll, and textAreaState.

 

All together it takes up about 17K. There is an additional class, TextAreaApp.class which is an example Applet showing the TextArea control.

 

To use the ScrollableTextArea

Again this is fairly simple.

  1. Create the ScrollableTextArea.
  2. Assign a font to the font member if you want to change the font.
  3. Get a ScrollableContainer for it by calling ScrollableTextArea.getScrollableContainer().
  4. Add the ScrollableContainer to your container and set it’s size using setRect().
  1. Use setText() and getText() to set and get the text of the ScrollableTextArea control.

 

The classes you would need to use the ScrollabeTextArea are all the ones needed by TextArea and the following additional classes: ScrollableTextArea, ScrollClient, ScrollServer, mScrollEvent, TrackControl, ScrollTrack, ScrollBar, and ScrollableContainer.

 

This adds on another 10K. There is an additional class, ScrollabeTextAreaApp.class which is an example Applet showing the ScrollableTextArea control.