The procedure for drawing an image on a java.awt.Panel or on a Canvas is much the same as shown below. It is not recommended to mix AWT and Swing so you use a java.awt.Applet vis–a–vis JApplet and the Panel/Canvas paint method with signature
In AWT drawing you may find value in overriding the update method; sometimes like this to avoid flickering
but this will vary according to what you are doing and want to achieve. Swing painting tends to be easier than painting in the AWT. The override of the getPreferredSize method is for the JScrollPane. You can use the setPreferredSize instead if you like. setPreferredSize is part of the Component api (okay for use in AWT) as of j2se 1.5
Can you please tell me why when I invoke the paint method my panels and Menubar and sometimes buttons are painted over. It'll paint the image in the panel but ma other components and panel will be jst covered white
Post by:autobot
The City calls upon her steadfast protectors. Now for a tiny ad:
a bit of art, as a gift, the permaculture playing cards