简体   繁体   English

旋转面板中的背景颜色错误

[英]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. 正如您在代码中看到的那样,颜色是红色200,绿色200和蓝色200。当我捕获屏幕并捕获颜色时,结果是红色210,绿色210和蓝色210。非常奇怪。 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. 这已在MacOSX 10.10.1和Java 1.6中进行了测试。 I also tested in older versions of MacOSX with the same result. 我还在较旧版本的MacOSX中进行了测试,结果相同。

Any idea? 任何想法?

Thanks 谢谢

Imagen with the test result: http://picpaste.com/Screen_Shot_2014-12-08_at_00.21.37-85tIkP30.png 带有测试结果的图像: 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. 我发现这发生在VM 1.6.0_65-b14-466.1。 I have tested in 1.7.0_67 and 1.8.0_20 and work correct. 我已经在1.7.0_67和1.8.0_20中进行了测试,并且可以正常工作。 Strange behaviour but at least I found it. 奇怪的行为,但至少我发现了。 Still don't know why. 还是不知道为什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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