aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Setting the Z order of a JComponent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting the Z order of a JComponent" Watch "Setting the Z order of a JComponent" New topic
Author

Setting the Z order of a JComponent

Kory Spansel
Greenhorn

Joined: Mar 05, 2002
Posts: 6
Is it possible to set the z order value for a JComponent? I have a custom layout manager and some of my components overlap the problem is that the components are being drawn on top of each other in the wrong order. Thanks
Kory
[ March 12, 2002: Message edited by: Kory Spansel ]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Since the content pane is contained in a JLayeredPane you can add the JComponent component to layer 10 by calling,

on your JFrame. The JavaDocs say that you should do this before actually adding the component to the content pane.

You can also do this with :


But since you are using a custom layout manager the first option may meet your needs better.

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Kory Spansel
Greenhorn

Joined: Mar 05, 2002
Posts: 6
Thanks for the reply but I don't think thats exactly what I'm looking for. Basically what I have is a class derived from a JComponent called StandardCard and I also have a class called CardTable derived from JPanel in which I add my StandardCards to. So I wanted to write a layout manager for the CardTable class to use. And then I will place the card table class, along with some other stuff onto a JFrame. So basically I don't have a JLayeredPane component. I have no problems setting the bounds of each component within the layout manager it's just that it draws the first component on top and the successive components underneath the previous one. It looks like your holding your poker hand upside down
Kory
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Oh, sorry... But from what you said it sounds like the solution to your problem is easy... Just draw the cards in reverse order and they will lie on top of each other correctly!

-Nate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting the Z order of a JComponent
 
Similar Threads
Custom Layout Manager
Using graphics
swing components
Differnece between setVisible() and show() methods
Learning to use Drag and Drop