# Line thickness on Paintable Canvas

**URL:** <https://forum.inductiveautomation.com/t/line-thickness-on-paintable-canvas/6103>\
**Category:** Ignition\
**Created:** [March 26, 2013, 6:24am UTC](https://forum.inductiveautomation.com/t/line-thickness-on-paintable-canvas/6103 "2013-03-26T06:24:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cas](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Cas](https://forum.inductiveautomation.com/u/Cas)\
**Post date:** [March 26, 2013, 6:24am UTC](https://forum.inductiveautomation.com/t/line-thickness-on-paintable-canvas/6103/1 "2013-03-26T06:24:38Z")

</div>

Hi, I have the following code to draw a line in the Paintable Canvas:

[code]from java.awt import Color  
from java.awt import Graphics  
from java.awt import Graphics2D  
from java.awt.geom import Line2D

g = event.graphics

g.setColor(Color.RED)  
g.drawLine(event.source.xTA-7, event.source.yTA-9, event.source.xTB-7, event.source.yTB-9)[/code]

But I want to vary the thickness of the line. It seems that I might have to use setStroke in the Graphics2D object, but coding that is beyond me. Can anyone help here?

Thanks,  
Cas

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 26, 2013, 5:28pm UTC](https://forum.inductiveautomation.com/t/line-thickness-on-paintable-canvas/6103/2 "2013-03-26T17:28:27Z")

</div>

You can do the following:[code]from java.awt import Color  
from java.awt import Graphics  
from java.awt import Graphics2D  
from java.awt.geom import Line2D  
from java.awt import BasicStroke

g = event.graphics

g.setColor(Color.RED)  
g.setStroke(BasicStroke(3))  
g.drawLine(event.source.xTA-7, event.source.yTA-9, event.source.xTB-7, event.source.yTB-9)[/code]Notice the g.setStroke function call. Here is a list of functions you can use:

[docs.oracle.com/javase/7/docs/ap … phics.html](http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html)

---

<div class="post-metadata">

**Author:** ![Cas](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Cas](https://forum.inductiveautomation.com/u/Cas)\
**Post date:** [March 26, 2013, 7:52pm UTC](https://forum.inductiveautomation.com/t/line-thickness-on-paintable-canvas/6103/3 "2013-03-26T19:52:47Z")

</div>

Thanks, Travis. I will try this tonight.  
So the key here is: “from java.awt import BasicStroke”?

Because setStroke & BasicStroke are in the Graphics2D class, it never worked for me when trying to use it under the regular Graphics class. All I was missing was to import the BasicStroke object?  
Note, the setStroke reference wasn’t on the link that you provided, but it is on the Graphics2D page.  
[http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html](http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html)

Thanks for the clarification.  
Cas
