简体   繁体   中英

Wrong background color in swing panel

I'm having a strange behaviour with color in a swing test example. As you can see in the code the color is Red 200, Green 200 and Blue 200. When I capture the screen and capture the color the result is Red 210, Green 210 and Blue 210. Very strange. In some situation it's not a problem but in other it's.

This is tested in MacOSX 10.10.1 and java 1.6. I also tested in older versions of MacOSX with the same result.

Any idea?

Thanks

Imagen with the test result: http://picpaste.com/Screen_Shot_2014-12-08_at_00.21.37-85tIkP30.png

public class ColorTest {

  public static void main(String[] args) {
    JFrame frame = new JFrame();

    JPanel panel = new JPanel();
    panel.setBackground(new Color(200, 200, 200));

    frame.add(panel);
    frame.setMinimumSize(new Dimension(800, 600));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
}

I discover this happen in the VM 1.6.0_65-b14-466.1. I have tested in 1.7.0_67 and 1.8.0_20 and work correct. Strange behaviour but at least I found it. Still don't know why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM