Why Graphics objects don't overlap.
Code java:
class FirstDrawPanel extends JPanel
{
public void paintComponent(Graphics g)
{
g.setColor(Color.WHITE);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.setColor(Color.BLUE);
g.fillOval(xCoord, yCoord, 50, 50);
}
}
class SecondDrawPanel extends JPanel
{
public void paintComponent(Graphics g)
{
g.setColor(Color.WHITE);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.setColor(Color.ORANGE);
g.fillRect(xCoord, 0, 50, 50);
}
}
I want to know why the two Graphics objects don't overlap each other.
Can anyone help?