Useful FAQ
how to scroll the canvas?
no easy way
what is "peer" ?
using when porting to different platform
what is "addNotify"?
can image be a graphics object?
no, not a component either.
what is imageobserver?
use "this" usually ok.
how to show image without changing background?
use three image buffers, they will be contents-independent.
what is layout in a container ?
how to arrange things in the container.
why "prepare image" ?
getimage not load immediately, use "prepareimage" to delay until loaded.
how to show components in right place?
always "reshape" in the paint().
can constructor be overrided ?
use "super.constructor()" to call parents' constructor.
how to switch between threads ?
sleep some time in the main loop to let other threads get control.
update and init are two threads ?
ya, so explicit synchronized if needed.
writeChar vs. writeBytes ?
writeChar will cause trouble when reading from the input stream
writeBytes is ok.
is "new a thread" == "start a thread" ?
no, we have to call thread.start
readline vs. writechar ?
readline will take '\n' away.
how to convert image to int array and convert it back ?
Image => Int array
pg = new PixelGrabber(Image,0,0,width,height,pix_src,0,width)
where pix_src is Int[w*h] integer array.
Int array => Image
Image img = createImage(new MemoryImageSource(w, h, pix_src, 0, w));