Changing AWT line thickness

To change the line thickness from thin bands to thicker bands, like below:

line thickness

Set the “stroke” size used on the Graphics2D object:

 
   Graphics2D graphicsSG2D = ((Graphics2D) graphics);
   if(graphics instanceof Graphics2D) 
   {
      stroke = graphicsSG2D.getStroke();
      graphicsSG2D.setStroke(new BasicStroke(3));
   }

   if(graphics instanceof Graphics2D && stroke != null)
   {
      graphicsSG2D.setStroke(stroke);
   }

Don’t forget to save the previous stroke type, using

graphics2D.getStroke()

and then reset it after drawing this alternative-thickness line.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s