posted 20 years ago
Using the paint method in an Applet or JApplet is tricky because it will draw on top of everything, including your components (see api). An easier way to get started is to use a separate image component as the content pane, set its layout and add the components to it. The image will be in the background. In Swing ('J' prefix on the components) we usually do not need to override the update method though it is common to do so for different uses in the AWT. Loading images inside an applet that has a main method is also tricky: you need an applet method, which you have above, for applet context and an application method, as in Toolkit with MediaTracker or ImageIcon, for the application context. You can avoid this with an inner or outer class that loads its own image (or with the newer ImageIO class - j2se 1.4).