hello,
I have been meessing around with a simple drawing tool. It is an example out of begining Java 2. As an extra I was trying to add a draw triangle but got a little bit stumped. I can get the button to draw a static triangle. One size one place, but I wanted to be able to create a triangle of any size anywhere in the frame.
Below is the simple code to produce a satic triangle:
triangle= new GeneralPath();
triangle.moveTo(50.0f, 50.0f);
triangle.lineTo(150.0f, 50.0f);
triangle.lineTo(100.0f, 100.0f);
And below here is what i am trying for but not quite getting right. I want the user to click on the frame to start the triangle. Then two more clicks to produce the triangle:
public Triangle(Point start, Point next, Color color) {
super(color);
triangle= new GeneralPath();
triangle.moveTo(start.x, start.y);
// Add another side
public void modify(Point start, Point next) {
triangle.lineTo(150.0f, 50.0f);
triangle.lineTo(100.0f, 100.0f);
triangle.closePath();
}
}