On 24.11.2016 18:33, Alan Snyder wrote:


On Nov 24, 2016, at 7:18 AM, Semyon Sadetsky <semyon.sadet...@oracle.com <mailto:semyon.sadet...@oracle.com>> wrote:

If someone(in the application) change the background to transparent color then it should change opaque state as well.
Can you prove this statement at least with a reference to spec? It seems JComponent does not imply this.

The spec could be clearer with regard to painting a translucent color, but the implication is clear from the term “show through”. Painting a translucent color allows the pixels underneath to show through, so the components that provided those pixels must be repainted.
"A non-opaque component paints only a subset of its pixels or none at all...". Per-pixel translucent component paints all its pixels. This is not clearly states that per-pixel translucent component shall be non-opaque. I see an obvious inconsistency in a way we handle translucent JComponent and Window. This, of cause, need to be resolved somehow. We could forcibly make JComponent to be non-opaque as well as this is done for Window, or take translucency into account during the painting.

The Window#isOpaque() spec states:

The method returns false if the background color of the window
is not null and the alpha component of the color is less than 1.0.

Even with this absolutely clear spec the opaque property is set to false automatically with assigning transparent background to the window, and it doesn't require from user to keep them consistent.



public boolean isOpaque()
Returns true if this component is completely opaque.

An opaque component paints every pixel within its rectangular bounds. A non-opaque component paints only a subset of its pixels or none at all, allowing the pixels underneath it to "show through". Therefore, a component that does not fully paint its pixels provides a degree of transparency.



Reply via email to