I have a program with some gui, on the JFrame I set, setBackground( new Color(107, 106, 104) ); [The problem] It gives a greyish color, but not the right one! If I check the gui color in Photo Shop, it gives me the RGB values (126, 125, 123)
you cannot set setBackground
for JFrame
, it is only possible for ContentPane
, for example
JFrame#getContentPane.setBackground(new Color(107, 106, 104));
EDIT
from code
import java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class Check extends JFrame { private static final long serialVersionUID = 1L; public void makeUI() { JFrame f = new JFrame(); f.getContentPane().setBackground(new Color(107, 106, 104)); f.setDefaultCloseOperation(EXIT_ON_CLOSE); f.setSize(new Dimension(300, 200)); f.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Check().makeUI(); } }); } }
source share