I have a program, and it runs in a jframe in full screen exclusive mode. I am trying to change the brightness of the jframe. I was wondering how i would implement this. I thought it might be possible to change all the colors of the images getting drawn to the jframe and make them brighter, but it still does not change how bright the screen actually is. How do programs normally implement something like this.
问问题
1157 次
2 回答
2
在绘制循环结束时:
g.setColor(new Color(0, 0, 0, 0.5f)); // 50% darker (change to 0.25f for 25% darker)
g.fillRect(0, 0, width, height);
于 2013-05-03T22:07:56.877 回答
1
我不确定这是否是最好的方法,但它确实有效。覆盖public void paint(Graphics g)
JPanel 的方法,然后首先调用super.paint(g);
并在其上方绘制一个透明的黑色矩形。
像这样的东西:
private static Color BG = new Color(0, 0, 0, 100);
@Override
public void paint(Graphics g) {
super.paint(g);
g2.setColor(BG);
g.fillRect(0, 0, getWidth(), getHeight());
g.dispose();
}
使用新值而不是 100 更改颜色以更改暗度。
于 2013-05-03T22:09:08.370 回答