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 / GUI / July 2009

Tip: Looking for answers? Try searching our database.

Rendering in front of sub-components?

Thread view: 
Jarrick Chagma - 29 Jun 2009 19:36 GMT
I have a JPanel which is positioned to fill a JFrame and this panel has
other sub-panels arranged in a GridLayout.  Is it possible to do some
rendering of lines, rectangles etc. in the surrounding panel in such a way
that the graphics appear in front of all the sub-panels?  I need to do some
rendering that is limited to the surrounding panel but which cuts across
some of the sub-panels and appears in front of them.

Signature

Regards,

Jarrick

------------------------------------
Jarrick.Chagma@your.mind.gmail.com
(Lose your mind before emailing me)

Thomas A. Russ - 29 Jun 2009 21:32 GMT
> I have a JPanel which is positioned to fill a JFrame and this panel has
> other sub-panels arranged in a GridLayout.  Is it possible to do some
> rendering of lines, rectangles etc. in the surrounding panel in such a
> way that the graphics appear in front of all the sub-panels?  I need to
> do some rendering that is limited to the surrounding panel but which
> cuts across some of the sub-panels and appears in front of them.

I would think that if you created your own subclass of JPanel and
overrode the paintComponent method, you could do this.  Just have the
paintComponent method call the super method, and then do your own
rendering.  That would cause the panel's items to appear on top.

Signature

Thomas A. Russ,  USC/Information Sciences Institute

Knute Johnson - 29 Jun 2009 22:32 GMT
> I have a JPanel which is positioned to fill a JFrame and this panel has
> other sub-panels arranged in a GridLayout.  Is it possible to do some
> rendering of lines, rectangles etc. in the surrounding panel in such a
> way that the graphics appear in front of all the sub-panels?  I need to
> do some rendering that is limited to the surrounding panel but which
> cuts across some of the sub-panels and appears in front of them.

How about the GlassPane of the JFrame?

http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html

Signature

Knute Johnson
email s/nospam/knute2009/

Christian Kaufhold - 03 Jul 2009 15:43 GMT
> I have a JPanel which is positioned to fill a JFrame and this panel has
> other sub-panels arranged in a GridLayout.  Is it possible to do some
> rendering of lines, rectangles etc. in the surrounding panel in such a way
> that the graphics appear in front of all the sub-panels?  I need to do some
> rendering that is limited to the surrounding panel but which cuts across
> some of the sub-panels and appears in front of them.

A component cannot easily paint something on top of its children because
the children may be repainted directly without the parent knwoing.

There are basically two ways to do it:
a) add a bogus transparent child at the beginning which covers the whole component
(You need to override isOptimizedDrawingEnabled()!)
or
b) add a bogus transparent sibling after the component (then the parent
needs to override isOptimizedDrawingEnabled()).

The you can override paintChildren(Graphics) and paint after super.paint-
Children().

Also see: http://groups.google.com/group/comp.lang.java.gui/browse_thread/thread/579a14b53
0ef30f2/57d8c6d454e5f862



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



©2010 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.