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 / September 2005

Tip: Looking for answers? Try searching our database.

a swing component on top of another

Thread view: 
alex_us01 - 30 Sep 2005 17:20 GMT
hello,

Is it possible to put a swing component on top of another and
make at least the one on the top transparent so that the
contents of both are visible?

My specific problem is that I am using a package (JUNG) that
knows how to draw graphs (vertices and edges, etc.),
but I want to draw rectangles around groups of vertices,
and add text over or under the rectangles (via JLabels).
It is not possible to put these directly in JUNG's GraphDraw
Swing component. Therefore, I am looking for a way to put my
components separately on top of it visually and make them transparent
so that the contents of the underlying GraphDraw component are visible.

  thanks,
alex
alex_us01 - 30 Sep 2005 18:31 GMT
I found JLayeredPane. Maybe with JComponent.setOpaque(false) will work
I hoped. But when I tried to use JLayeredPane, nothing in it shows up.

I will post that in another topic with name "JLayeredPane possible in
BorderLayout.CENTER ?"

thanks,
alex
Tor Iver Wilhelmsen - 30 Sep 2005 21:23 GMT
> Is it possible to put a swing component on top of another and
> make at least the one on the top transparent so that the
> contents of both are visible?

setOpaque(false) is your friend.
Roedy Green - 30 Sep 2005 21:29 GMT
>Is it possible to put a swing component on top of another and
>make at least the one on the top transparent so that the
>contents of both are visible?

Transparent does not mean quite the same thing as it does in ordinary
English.  Fully transparent means the final colour is made by adding
up the r g b of the layers.  Black covers nothing. White obliterates
any detail on other layers. It is counterintuitive, but logical.

For overlapping components see
http://mindprod.com/jgloss/jlayeredpane.html

I have never tried this, but I would think you should get some
transparent effects just by drawing your components with colours with
an alpha channel (the high order byte of a 32-bit colour number) with
something other than 255 (fully opaque). Try setting it at 127 to
start.

The transparency I am familiar with is creating png and screen bit
images where you paint with partly transparent colours. See
http://mindprod.com/applets/masker.html for sample code.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



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



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