James Barrett wrote:
>Hi all, I am experimenting with JApplet and JPanel.
Be prepared for a world of trouble, dealing with applets.
Do you really need an applet, or just something that
can be launched from a link? If the latter, look instead
to a JFrame and Java Web Start.
>My JApplet contains a JPanel called jpanel1 size 210x210.
I created a class myPanel which extends JPanel and I set its size to
210x210.
myPanel contains a Canvas ...
You should not mix Swing and AWT, though I suspect
this is not the source of the propblem here.
>..called canvas1 and its size is 210x210.
Setting the preferredsize of the innermost component
should suffice in most situations, but that all becomes
redundant with applets in the sense that the entire GUI
is restrcted to the size set in the HTML.
>But when I run the applet and draw an image to the canvas1, it is not
visible.
I call canvas1.setVisible(true), myPanel.setVisible(true) and
jpanel1.setVisible(true) and still my image is not visible.
All these calls to setVisible() are redundant.
>I set canvas1.setLocation(0,0), myPanel.setLocation(0,0) and still my
image is not visible.
These calls are redundant so long as the applet
uses layouts, if it does not use layouts, it should.
If you simply aComponent.add(anotherComponent),
there will be a layout present.
>Is there something else that I should try to make the image visible?
MediaTracker.
There was a recent thread re. fading an image in an applet..
<http://www.javakb.com/Uwe/Forum.aspx/java-setup/10820/Fading-effect>
Look for Knute Johnson's code example, that shows
how to do it in a frame.
I turned the OP's version of Knute's code into an applet
that you can see here. The code is linked.
<http://www.physci.org/test/applet/slideshow/>
Failing that, try posting an SSCCE.
<http://www.physci.org/codes/sscce.html>
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200710/1