I created a JFrame and set the color to white with setBackground(Color.WHITE), but the color is not white but a bit gray.

I created a JFrame and set the color to white with setBackground(Color.WHITE), but the color is not white but a bit gray.

Doing frame.setBackground() won't work. You need to do it like this:
frame.getContentPane().setBackground(Color.white);