Presuming they are added to the same container and the layout makes the components intersect: they get painted one after another in the order they where added.
// comp0 will be painted above comp1 if they intersect:
container.add(comp0);
container.add(comp1);
or:
container.removeAll();
container.add(comp0);// components: only comp0
// adding comp1 "above" comp0 like this:
container.add(comp1, 0);// components comp1, comp0
container.add(comp2, 1);
// now you have the order comp1, comp2, comp0
";-)
Ragnvald Barth
Software engineer
Are your components realy intersecting?
If you want two components to intersect, the last of them will be partly hidden.
import java.awt.*;
class myPan extends Panel
{
Button but1;
Button but2;
public void doLayout()
{
but1.setBounds(0, 10, 40, 40);
but2.setBounds(20,5, 40, 50);
}
myPan()
{
but1=new Button("but1");
but2=new Button("but2");
add(but1);
add(but2);
}
}
In the code above, but1 will be partly hidden by but2.
";-)
Ragnvald Barth
Software engineer