アプリケーションで長方形を赤い色合いでペイントしようとしていますが、その下のコンポーネントが引き続き表示されるように、ある種の透明にする必要があります。しかし、私はまだいくつかの色がまだ表示されることを望んでいます。私が描いている方法は次のとおりです。
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);
}
}
}
赤い色合いを少し透明にする方法を知っている人はいますか?完全に透明にする必要はありません。