Posted By:
vijay_solanki
Posted On:
Saturday, October 22, 2005 04:18 AM
Hi, I have an application in which I have to display one rectangular box moving while mouse is dragged. I wrote the code. When I use draw() method of Graphics2D class with stroked shape, the box does appear, but suddenly it disappears giving a blinking box. On the other hand, when I use drawRect() method the green box is shown correctly. Also, When I use draw() with stroked shape as parameter, the rectangle drawn is fully shown above all other background colors ( in my case it is an image on which i m drawing rectangle ). But when I use drawRect() method, the rectangle is hidden behind the colors except black. code is like this: Graphics2D g2d = getGraphics();
More>>
Hi,
I have an application in which I have to display one rectangular box moving while mouse is dragged. I wrote the code. When I use draw() method of Graphics2D class with stroked shape, the box does appear, but suddenly it disappears
giving a blinking box. On the other hand, when I use drawRect() method the green box is shown correctly.
Also, When I use draw() with stroked shape as parameter, the rectangle drawn is fully shown above all other background colors ( in my case it is an image on which i m drawing rectangle ). But when I use drawRect() method, the rectangle is hidden behind the colors except black.
code is like this:
Graphics2D g2d = getGraphics();
g2d.setXORMode(Color.green);
BasicStroke b = new BasicStroke(...);
/*The box drawn with this is not fully drawn (only the lines above black background are showing)*/
//g2d.drawRect(rect.x, rect.y, rtect.width, rect.height);
g2d.draw(b.createStrokedShape(rect));
getGraphics().setPaintMode();
Thanks in anticipation.
- Vijay
<<Less