Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes OverlayLayout? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: OverlayLayout?
 
Similar Threads
Layered JPanels Transparency Problem.
Issue regarding Glass Pane
constructing a component (beginner)
Is this possible to do?
Display two Frames In One Window?