Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting the Z order of a JComponent

 
Kory Spansel
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kory Spansel
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic