Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

How to make two JPanel overlapping

Thread view: 
iherage - 07 Aug 2007 12:09 GMT
I have two JPanels which have some graphics drawn on the panel. Now I
want to have the two panel overlapping one the same JPanel so that two
graphics on the panels will display together.

Can anyone give some clues how to do this?

Thank you.
Thomas Hawtin - 07 Aug 2007 14:46 GMT
> I have two JPanels which have some graphics drawn on the panel. Now I
> want to have the two panel overlapping one the same JPanel so that two
> graphics on the panels will display together.
>
> Can anyone give some clues how to do this?

You need to do two things:

 o setOpaque(false)
     Opaque may or may not already be false. For a JPanel it depends
upon the installed PL&F. One would also need to set this after PL&F is
changed (the interface between components and PL&F is poorly defined).

 o Override isOptimizedDrawingEnabled of the parent container to return
false.
     This is a bit of magic to make sure the parent paints its children
correctly. One would have thought it computationally efficient enough
for the container to work it out itself, but unfortunately the poor
optimisation is exposed.

I suggest using JComponent instead of JPanel. JPanel carries with it
unnecessary baggage.

Tom Hawtin


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.