Hi ,
I have an applet with some hand drawn components on.
Basically I repaint the canvas that each component is drawn on when the user
clicks or presses a key.
This works fine, but, not I have been asked to serialize the drawings so
they can be reloaded when the applet starts up.
Sounds simple enough, I simply retrace the "add component" and "draw stuff"
steps I used when they clicked the mouse etc... In a round about way!
Anyhow, I am seeing a strange problem where say I have two components
sharing a main panel using a GridBagLayout. (By the way this is all AWT).
I can happily add and remove the 2nd component when the user clicks a mouse
on a button for example, and I can resize both components to fit. However
when I call this code from the Applet.start() method, it appears that the
first compoents will draw itself, but the 2nd does not (And the first
component has not resized accoringly). Clicking a button called refresh,
which, you guessed it, calls the redraw routines (The same routines called
from the start() of the applet) seems to sort everything out.
Now, both routes call exactly the same lines of code.. The only difference
has to be the thread from which the call is made. I am assuming events from
mouse and key presses are fromt he UI thread, and that the applet.start()
methods is called from elsewhere.. Would this be the case, and could it
cause my problem?
I have not posted code here as htere is a lot of it, and probably not very
helpful.. Just assume an applet with a Panel that fits the entire Applet
client area. The inner panel then gets two Canvas subclasses added to it, at
50% height each...
Long shot, but hope you can help!
Steve
Andrew Thompson - 20 May 2005 16:47 GMT
> I have not posted code here as htere is a lot of it,
...maybe trimming it to the bare minimum that displays the
problem - will reveal the solution.
<http://www.physci.org/codes/sscce.jsp>
Just a thought.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
SPG - 20 May 2005 16:56 GMT
>> I have not posted code here as htere is a lot of it,
>
[quoted text clipped - 3 lines]
>
> Just a thought.
Yeah, you are not wrong there!
I think I have solved and it was definitely due to the way the applet was
drawing on different threads.
I was getting errors when creating an off screen image saying that the width
and height cannot be 0, all sorts of weird stuff!
Anyway, I think I have managed to keep all drawing on the same thread now,
and that seems to have fixed it.
Steev
Andrew Thompson - 20 May 2005 16:56 GMT
> ..using a GridBagLayout.
Perhaps before you go to the effort of an SSCCE, you might try
swapping the GBL for a GridLayout and see if the problem persists.
HTH

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane