File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JLayeredPane + JPanel problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JLayeredPane + JPanel problem" Watch "JLayeredPane + JPanel problem" New topic
Author

JLayeredPane + JPanel problem

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
I tried to overlay 2 buttons over the JLayeredPane. So that 2 buttons can be rendered over the title bar.



But the buttons' and JPanel's Z-orders are wrong, which the image is behind the Buttons, I'd like to see the image thru the JPanel's.
How can I do that?
Thanks
Jack
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2156
    
    7
Read the Swing tutorial on How to Use Layered Panes for working examples.

You need to specify an Integer value when you add components to the layered pane to control the order in which components are painted. Also I would not extend JLayeredPane. Just add compnents to it.

Post your SSCCE demonstrating the problem if you need more help.
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
Rob Camick wrote:Read the Swing tutorial on How to Use Layered Panes for working examples.

You need to specify an Integer value when you add components to the layered pane to control the order in which components are painted. Also I would not extend JLayeredPane. Just add compnents to it.

Post your SSCCE demonstrating the problem if you need more help.


Got it working, by setting setOpaque to false for the JPanels
 
wood burning stoves
 
subject: JLayeredPane + JPanel problem
 
Similar Threads
Swing GUI wierdness
create a jtable which can combine and split and the image change also
gridlayout - set size
Painting components over images
How do read a double datatype 2D array into your applet code from a text file