我试图在我的应用程序上画一个矩形在红色阴影,但我需要使它的透明度,使其下的组件仍然会显示。但是我仍然希望有些颜色仍然会显示出来。我正在绘制的方法如下:
protected void paintComponent(Graphics g) {
if (point != null) {
int value = this.chooseColour(); // used to return how bright the red is needed
if(value !=0){
Color myColour = new Color(255, value,value );
g.setColor(myColour);
g.fillRect(point.x, point.y, this.width, this.height);
}
else{
Color myColour = new Color(value, 0,0 );
g.setColor(myColour);
g.fillRect(point.x, point.y, this.width, this.height);
}
}
}
有谁知道我怎么能使红色的阴影有点透明?我不需要它完全透明。