Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes OverlayLayout? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "OverlayLayout?" Watch "OverlayLayout?" New topic
Author

OverlayLayout?

Laird Nelson
Greenhorn

Joined: Jan 10, 2003
Posts: 6
Any pointers on how to use OverlayLayout? I'd like to overlay a button on a label in the bottom right corner, but no matter what I do with alignmentX and alignmentY on either component, I can't get my panel--which has its layout set to a new OverlayLayout--to do anything even REMOTELY predictable.
Does anyone know how to work with this awful, undocumented class?
Thanks,
Laird
kyle amburn
Ranch Hand

Joined: Jul 29, 2001
Posts: 64
What OverlayLayout does is layout each component on top of the another component. It does not allow you to specify the precise positioning within the component. What I have done to use this class is extend it and override the layoutContainer method with the following code:

This uses the location specified by a components setLocation() methods top place the component absolutely in the x,y coordinates of the component with this layout. Just remember that when you use this layout, the first added component will appear on top.
Kyle
Laird Nelson
Greenhorn

Joined: Jan 10, 2003
Posts: 6
Originally posted by kyle amburn:
What OverlayLayout does is layout each component on top of the another component. It does not allow you to specify the precise positioning within the component. What I have done to use this class is extend it and override the layoutContainer method with the following code:

This uses the location specified by a components setLocation() methods top place the component absolutely in the x,y coordinates of the component with this layout. Just remember that when you use this layout, the first added component will appear on top.
Kyle

OK; but various references I've stumbled across say that the components will be laid out with their "alignment points on top of each other" (see O'Reilly's Nutshell book, for example). So I would think that just using setAlignmentX and setAlignmentY that I could achieve *relative*, not absolute, positioning. But this doesn't seem to be the case at all. Any ideas?
Laird
 
 
subject: OverlayLayout?
 
Similar Threads
Layered JPanels Transparency Problem.
constructing a component (beginner)
Display two Frames In One Window?
Is this possible to do?
Issue regarding Glass Pane