Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JFrame setBackground failure with contentPane

807601Apr 15 2008 — edited Apr 16 2008
Hi. This is the first time I am using swing and I seem to be having some trouble. Compiling my code in java 5 and running it on a mac seemed to work fine, but as soon as I went over to a PC (I am a PC user myself) I got some problems. I've seen plenty of suggestions to use getContentPane().setBackground(*color*), but when I tried that it didn't change anything. When I run my program the frame pops up and whatever was behind it at the time it was created becomes the background. Everything that I paint just gets painted over that background, and it doesn't refresh, so if I move a square across the frame it will leave a trail behind itself. The reason I am using swing is mainly for it's double-buffering, so filling in my background every time paint() is called is just a waste and brings me right back to the flicker problems I have with awt. Does anyone know why this is happening and how I can fix it?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2008
Added on Apr 15 2008
27 comments
394 views