Does Graphics2D reset the composition the every time paintComponent() is called? And why?
For example,
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
System.out.println(((AlphaComposite)g2.getComposite()).getAlpha()); //printing alpha value before setting composition
g.drawImage(background,0,0,500,500,null);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
g.setColor(Color.RED);
g.fillOval(x-100,y-100,200,200);
System.out.println(((AlphaComposite)g2.getComposite()).getAlpha()); //printing alpha value after setting composition
}
The above code print the following when paintComponent() is called couple times...
1.0
0.5
1.0
0.5
1.0
0.5
1.0
0.5
does this mean graphics2D reset the composition after paintComponent(), why does it have to do it?