File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes having some minor problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "having some minor problems" Watch "having some minor problems" New topic

having some minor problems

Martin vanPutten
Ranch Hand

Joined: Mar 26, 2006
Posts: 124
I havn't done an applet in a while. Can somebody point out why I'm not viewing anything within the applet? Also, I want to double buffer it but I had to comment out the getContentPane(). It says that it could not read it. Any reason for that as well?

Live And Let Learn.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
First, you probably meant to extend JApplet.

Also notice the capitilization of Painter.
Vishal Mungi

Joined: Mar 24, 2005
Posts: 24
If you extend applet you add components directly :

add(new painter());

If you extend JApplet you add components to the content pane:

getContentPane.add(new painter());

when extending a JPanel you override the paintComponent method & not paint

Also, dont forget to call super.paintComponent first.
[ December 07, 2006: Message edited by: Vishal Mungi ]
Martin vanPutten
Ranch Hand

Joined: Mar 26, 2006
Posts: 124
The getContentPane compiles now... and Painter class is capitalized but it still doesn't give me a black background. I feel like i'm missing something. Any suggestions?
I agree. Here's the link:
subject: having some minor problems
jQuery in Action, 3rd edition