Hi to all,
i call the method drawArrow that i describe below.When i pass as argument
a Graphics object i want my program to draw a GREEN arrow.
However when i pass as argument a Graphics2D object i want my program to
draw a RED arrow.
The problem is that i am always getting a GREEN arrow.Why does this
happen?What
===========================================================
public void drawArrow(Graphics g, int x1, int y1, int x2, int y2){
if (g.getClass().getName().equals("Graphics2D")) { // graphics2d object
Graphics2D g2=(Graphics2D)g;
g2.draw(new Line2D.Double(x1,y1,x2,y2));
GeneralPath arrow = new GeneralPath();
arrow.moveTo(xValues[0],yValues[0]);
arrow.lineTo(xValues[1],yValues[1]);
arrow.lineTo(xValues[2],yValues[2]);
arrow.lineTo(xValues[0],yValues[0]);
g2.setColor(Color.red);
g2.fill(arrow);
}
else // graphics object
{
g.drawLine(x1,y1,x2,y2);
g.setColor(Color.green);
g.fillPolygon(xValues,yValues,3);
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".