I have a GOval object lets call it circle which I am using in an applet. I added the GOval object to the container and then below the line where I added it to the container I typed the following lines of code in:
circle.setFilled(true);
circle.setFilledColor(Color.WHITE);
but I don’t understand why this worked? Because I already added the circle to the container before these two lines so how is the circle getting filled with white color when my applet is displayed?
So does this mean that even the organization of the various objects into different layers like sending objects to back or bringing objects to front can be done after adding those respective objects to the container?
You created a variable called circle. Or more correctly, you have a reference to a variable called circle. (the variable points to the memory location of the variable)
When you add it to the container, the container now links to that memory address for that position in the container (let’s say you had a basic array, position 0 in the array points to that memory address)
When you change the object at that memory address (regardless of whether you change it from your variable called circle, or container object 0)…the fact is, their pointing to the same memory location – same object!