• Post Reply Bookmark Topic Watch Topic
  • New Topic

interesting question!!!!!!!  RSS feed

 
Surya Renduchintala
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys!
can someone tell me how can I increase the width of a line while we draw using g.drawLine(int x,int y,int x1,int y1);
thanks in advance
surya.
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can brief the explanation
Thanks,
angela
 
Daniel Searson
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into using a Graphics2D instead of Graphics to draw the line. I'm pretty sure Graphics does not contains methods for changing the thickness of a line (no ones stopping you from writing your own) but Graphics2D definetely does.
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surya,
Daniel is right you need to got o the Graphics2D class. What your looking for is the setStroke method. It works on an instance of a Graphics2D object and takes a BasicStroke object as a parameter to its constructor. A quick and simple way to do it is something like this:
Graphics2D g2 = (Graphics2D)g;
g2.setStroke(new BasicStroke(2.0f));
now all of the lines you draw in either the Graphics2D class or the regular Graphics class will have a width of 2. Remember to change it back to 1 when your done.
hope that helps
Dave
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted an answer to this same question a while back in this thread...

HTH,
-Nate
 
Surya Renduchintala
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot guys
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!