Re: implementing paint




"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


.



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)