Question

I made a Java application in NetBeans with a custom JPanel. I set the background of the panel to white in multiple locations, including in the GUI Builder, in the initializing code for the application, and in the constructor for the Panel. Despite this, whenever I run or preview the application, under any of the Look & Feels that NetBeans lists (Metal, Nimbus, CDE/Motif, Mac OS X), the panel shows up in the same weird grey as the default background color. However, the panel is also in a ScrollPane (whose background is also supposedly white), and any part of the panel that goes off the edge of the ScrollPane becomes white when I scroll back to it. Does anyone know what could cause this behavior?

Was it helpful?

Solution

Ok, I figured it out. The clearRect command I was using to repaint the custom panel uses the background color of the drawing surface, which for some reason is not the color I set the panel's background to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top