HappyGoLucky
January 30th, 2003, 05:05 PM
Hello, I wrote a Java applet that allows people to draw lines by dragging the mouse cursor. What I need to do is to be able to vary the thickness of the line. I have tried doing this with the BasicStroke method and then calling setStroke(...). Am I on the correct path here. Meaning calling BasicStroke. If so can someone tell me the proper way to call the method to vary the line length. Here is the code snippet I am using. Thank you in advance!!!
BasicStroke newStroke = new BasicStroke(2,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,1.0,1.0,1.0);
g2d.setStroke(newStroke); // g2d is a Graphics2D object
// ALso note that I use the api call drawLine to draw the line.
g2d.drawLine(p1.x,p1.y,p2.x,p2.y);
BasicStroke newStroke = new BasicStroke(2,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,1.0,1.0,1.0);
g2d.setStroke(newStroke); // g2d is a Graphics2D object
// ALso note that I use the api call drawLine to draw the line.
g2d.drawLine(p1.x,p1.y,p2.x,p2.y);