javaswinghexrgbsetbackground

setBackground(new color()); in java does not understand the given RGB value


I have a program with some gui, on the JFrame I set,

 setBackground( new Color(107, 106, 104) );

The issue is that I get a greyish color, but not the right one. If I check it in PhotoShop, it gives me the RGB values (126, 125, 123)

Ps. I have tried with HEX value, the same result.


Solution

  • I have a program with some gui, on the JFrame I set,

    setBackground( new Color(107, 106, 104) );
    

    It gives a greyish color, but not the right one! If I check the gui's color in Photo Shop, it gives me the RGB values (126, 125, 123)

    You can not set setBackground for JFrame, this is only possible for ContentPane, for example

    JFrame#getContentPane.setBackground(new Color(107, 106, 104));
    

    EDIT

    enter image description here

    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();
                }
            });
        }
    }