Re: JPanel not visible in JApplet



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Barrett wrote:
Hi all, I am experimenting with JApplet and JPanel.

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 called canvas1 and its size is 210x210.


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.

I set canvas1.setLocation(0,0), myPanel.setLocation(0,0) and still my
image is not visible.

Is there something else that I should try to make the image visible?

Thanks,


I have narrowed it down but I don't fully understand why this is
happening. If I draw an image during the init() method nothing is
displayed, even if I put the setVisibale and setLocation method calls
before the drawImage method. But after the applet is inited, then images
can be drawn. but why? I want to display an image with out user
intervention, and as far as I know, that can only be done during init().
Is there another way?

Thanks,

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHABd8QuDJiZ/QrH0RAlvRAKCBqzN2qYUzR7YtgQQvSETBxWZEigCdEozA
7iNuJd1CkoRg2qBCnNNYOLY=
=mCN0
-----END PGP SIGNATURE-----
.



Relevant Pages

  • JPanel not visible in JApplet
    ... My JApplet contains a JPanel called jpanel1 size 210x210. ... I created a class myPanel which extends JPanel and I set its size to ... But when I run the applet and draw an image to the canvas1, ...
    (comp.lang.java)
  • Re: drawImage() Question
    ... If you acquire the whole image before you attempt to draw it you can put 'null' there. ... Here is an example of how to read an image file and draw it on a JPanel. ... public void paint{ ... java ImageIOExample http://www.thealpacastore.com/alpacacam/latest640.jpg ...
    (comp.lang.java.help)
  • Re: Getting my first custom JList to work
    ... > created a class that encapsulates each cell (and inherits JPanel) and have ... > Do I have to override paintComponentin my CustomListCellRenderer class ... can I use a JPanel to display items in a JList? ... explicitly set the text of all 3 JLabels but they are displaying as blank. ...
    (comp.lang.java.gui)
  • Re: =?ISO-8859-15?Q?!DisplayPanel_einem_JFrame_hinzuf=FCgen.?=
    ... ich habe eine Klasse Frame. ... In der soll ein neuer JFrame erzeugt werden. ... Dieses Display Panel ist ein normales JPanel dem einfach nur ein JTextField ...
    (de.comp.lang.java)
  • Setting Background partly transparent
    ... I need to draw a certain shape on a JPanel which follows ... mouseMotionListener for realising the move- effects. ... Is there a solution for making components partly transparent? ...
    (comp.lang.java)