Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ComponentZOder Questions

 
Stevo Johnson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
~Stevo
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure about 1 and 2, but 3 is in the API. It's in Container.
 
Stevo Johnson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Anyway, thanks for the reply, but does anyone know about 1) or 2)?

what happened when you tried them?

 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic