Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
To manipulate characters in a string itself, use java.lang.StringBuffer.
We create an instance with room for 50 characters initially. This is just to make it memory efficient, it can grow beyond 50.
Initially, the String "ABC12" is copied to the empty StringBuffer.
The character '3' is added.
Each button click, the '+' character is inserted as the 4th character.
The first character is copied to the end.
The TextArea.append method wants a regular String only as argument,...
..so we make one beforehand.
The StringBuffer class has many more interesting methods, like :
append ( char [ ] )
append ( double )
append ( int )
charAt ( int pos )
insert ( int pos, String )
reverse ( )
setCharAt ( int pos , char )
setLength ( int )
cut it short or give it more room.
As of 1.2 :
delete ( int from , int to )
replace ( int from , int to, String )