It's easy enough to create a short, runnable example to demonstrate a problem you're having with code. Saying it's too complex is just laziness. Here's 1) an example of how to do that, and 2) a demonstration of what I suspect is the source of your problem. Note the comment in the method buildJPanel(). If not, come back with a small, runnable example that demonstrates what you're seeing.
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
// a simple class to demonstrate the effect of opacity on background color
public class TestClass
{
public TestClass()
{
JFrame mainFrame = new JFrame( "Test Frame" );
mainFrame.add( buildJPanel() );
mainFrame.setLocationRelativeTo( null );
mainFrame.pack();
mainFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
mainFrame.setVisible( true );
}
public JPanel buildJPanel()
{
JPanel mainPanel = new JPanel();
// change the 'false' in the next line to 'true' to see what happens
mainPanel.setOpaque( false );
mainPanel.setBackground(Color.red);
mainPanel.setPreferredSize( new Dimension( 100, 100 ) );
return mainPanel;
}
// to launch TestClass on the EDT
public static void main( String[] args )
{
SwingUtilities.invokeLater( new Runnable()
{
public void run()
{
new TestClass();
}
});
}
}