File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes ComponentZOder Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ComponentZOder Questions" Watch "ComponentZOder Questions" New topic

ComponentZOder Questions

Stevo Johnson

Joined: Jun 01, 2009
Posts: 12
Hey all!

3 questions here:

1) Does each component within a container have a unique z-order int? In other words, when I use container.setComponentZOrder( component, 0 ) does that increment the z-order of all the other components in that container? If so I should be able to use this to implement "bring to front" "sent to back" etc. ala Microsoft Office.

2) I know the z-order effects the order that components are drawn in but does it also effect when mouseEntered and mouseExited events occur? If I add two overlapping components to a container, the second one added is drawn on top and receives mouse events for the overlapping region. If I bring the first component to the top using setComponentZOrder I want to change both the drawing order and the mouse event receiver.

3) Why aren't getComponentZOrder and setComponentZOrder documented in the Java API? Eclipse tells me they exist and provides documentation on them...

Thanks so much!
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46360
Not sure about 1 and 2, but 3 is in the API. It's in Container.
Stevo Johnson

Joined: Jun 01, 2009
Posts: 12
Weird....I went to the API pages for container, jcomponent, etc. and did a find on getcomponentzorder. I'm using firefox so as I typed getcomponent it found the method getcomponent() but as soon as i typed 'z' firefox said there were no hits.

I followed your link and tried it again and this time it was found. Perhaps before I had not waited for the page to fully load?

Anyway, thanks for the reply, but does anyone know about 1) or 2)?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Anyway, thanks for the reply, but does anyone know about 1) or 2)?

what happened when you tried them?

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
To find a methods parent class use the index link at the top of the javadoc, between "Deprecated" and "Help".

The idea about using zOrder was to change the draggingComponents zOrder to zero in mousePressed as it is selected, before you start dragging it. This will keep it on top of any other children while you drag it.
I agree. Here's the link:
subject: ComponentZOder Questions
It's not a secret anymore!