Re: implementing paint
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Wed, 21 Mar 2007 15:23:23 -0400
"Carramba" <user@xxxxxxxxxxx> wrote in message
news:46017533$0$488$cc7c7865@xxxxxxxxxxxxxxx
but now the problem is in this
public void paint(Graphics g) {
// TODO Auto-generated method stub
Graphics2D g2d = (Graphics2D)g;
super.paint(g);
Polygon p = new Polygon();
System.out.println(getBounds());
p.addPoint(getBounds().x+3, getBounds().y+3);
p.addPoint(getBounds().x+10, getBounds().y+3);
p.addPoint(getBounds().x+3, getBounds().x+10);
g2d.fillPolygon(p);
g2d.drawPolygon(p);
}
/* (non-Javadoc)
* @see java.awt.Component#getBounds()
*/
@Override
public Rectangle getBounds() {
// TODO Auto-generated method stub
return super.getBounds();
}
get bounds returns absolute position, but I would like to have relative
to by able to draw triangle..
The relative origin position is (0,0). I.e. call addPoint(3,3), and
not addPoint(getBounds().x+3,getBounds().y+3).
- Oliver
.
- References:
- implementing paint
- From: Carramba
- Re: implementing paint
- From: Andrew Thompson
- Re: implementing paint
- From: Carramba
- implementing paint
- Prev by Date: Re: implementing paint
- Next by Date: Re: Is HTML rendering truly possible with Java?
- Previous by thread: Re: implementing paint
- Next by thread: Requesting tips, comments for an EDT thread-safe game architecture
- Index(es):
Relevant Pages
|