|
-
October 15th, 2010, 11:49 AM
#2
Re: JComponent Doesn't Add To JFrame
The background isn't being drawn because you aren't drawing it. Calling setBackground sets the colour of the background it doesn't draw it, that's up to you to do in the paintComponent method. Also JComponents are transparent by default so if you should be setting it to opaque if you are going to draw a background.
Having said all that, your FishComponent should really be a FishTank which should extend JPanel and each of your Fish should be JComponents added to the JPanel.
They probably shouldn't all be on their own threads either, normally one animation thread handling all of the moving objects is sufficient.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|