我想在我的应用程序中绘制一个红色矩形,但我需要让它有点透明,以便下面的组件仍然可见。然而,我仍希望一些颜色仍然可见。我正在使用以下方法进行绘制:
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);
}
}
}
有谁知道如何使红色阴影稍微透明一些?但我不需要完全透明。