Re: implementing paint
- From: Carramba <user@xxxxxxxxxxx>
- Date: Wed, 21 Mar 2007 19:26:34 +0100
Andrew Thompson wrote:
On Mar 22, 12:43 am, Carramba <u...@xxxxxxxxxxx> wrote:
public void paint(Graphics g) {
Should be paintComponent(), for Swing classes
//draw triangle with color c ???
//how?
<http://java.sun.com/docs/books/tutorial/uiswing/painting/
practice.html>
Thanx that helped a bit;
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..
.}
}
Andrew T.
- Follow-Ups:
- Re: implementing paint
- From: Oliver Wong
- Re: implementing paint
- References:
- implementing paint
- From: Carramba
- Re: implementing paint
- From: Andrew Thompson
- implementing paint
- Prev by Date: Re: How to print a JTextArea?
- Next by Date: Re: implementing paint
- Previous by thread: Re: implementing paint
- Next by thread: Re: implementing paint
- Index(es):
Relevant Pages
|