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.