Graphics and Textfields

I was wondering if you use Graphics and objects like Buttons, Labels, and TextFields are they all drawn on the same graphics layer or is one of them drawn on top, if so which one?
[193 byte] By [AnyoneEB] at [2007-9-26 2:40:57]
# 1

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

Ragnvald at 2007-6-29 10:15:50 > top of Java-index,Desktop,Core GUI APIs...
# 2
so if I draw graphics over and after I draw my label then the graphics will apprear, but if I do the label last the label will appear?
AnyoneEB at 2007-6-29 10:15:51 > top of Java-index,Desktop,Core GUI APIs...
# 3

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

Ragnvald at 2007-6-29 10:15:51 > top of Java-index,Desktop,Core GUI APIs...
# 4
They aren't compontents! one is a textfield that doesn't like me and the other thing is graphics (drawString to be exasct)!
AnyoneEB at 2007-6-29 10:15:51 > top of Java-index,Desktop,Core GUI APIs...