Re: implementing paint



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.

.



Relevant Pages

  • Re: implementing paint
    ... public void paint{ ... // TODO Auto-generated method stub ... Polygon p = new Polygon; ...
    (comp.lang.java.gui)
  • Re: JMS How to send and receive a message
    ... you have created a JMS server and a topic? ... public void ejbRemove() throws EJBException ... // TODO Auto-generated method stub ... body is online? ...
    (comp.lang.java.programmer)