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 / February 2004

Tip: Looking for answers? Try searching our database.

Setting Background partly transparent

Thread view: 
Silvio Malitsch - 04 Feb 2004 19:29 GMT
Hello,

I have some trouble with designing my GUI for an application.
I need to draw a certain shape (circle, rectangle) on a JPanel which follows
the mouse move on that JPanel.
Well the problem is the background. I should be transparent and only showing
the current shape.
I used the paintComponent() method to draw the shape and a
mouseMotionListener for realising the move- effects.
On runtime, it paints many shapes (one for each mouse move) but it should be
just one.
Clearing the Graphics2D Object with the clear() method makes the component
be painted in the default background color.

Is there a solution for making components partly transparent?
Is there another simple way of realising this?

Thanks.
Andrew Thompson - 04 Feb 2004 20:14 GMT
...
> I have some trouble with designing my GUI for an application.

Yes, I can see that in the code you did not supply.
http://www.physci.org/codes/sscce.jsp

For the rendering, you might get some leads from..
http://www.physci.org/launcher.jsp#JAnimateFrame

Since I did not really understand your vague
description, that is as much as I can help you
without an SSCCE..

--
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology
ak - 07 Feb 2004 03:39 GMT
> I used the paintComponent() method to draw the shape and a
> mouseMotionListener for realising the move- effects.
> On runtime, it paints many shapes (one for each mouse move) but it should be
> just one.

thats simple:

on every mouseMove() event you need to set Graphics to XOR mode.

then you paint your shape and save current coords.
on next event you paint shape on saved coords, then at new coords, and so
on.

____________

http://reader.imagero.com the best java image reader.


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.