Reputation: 15057
I want to know,how to draw the slanting line with thickness using the graphics.Any ideas how to achieve this?
Regards
Rakesh Shankar.P
Upvotes: 1
Views: 730
Reputation: 7915
Another possibility would be to draw a rectangle:
int[] xPts = { 20, 40, 240, 220 };
int[] yPts = { 40, 20, 220, 240 };
graphics.setColor(Color.GREEN);
graphics.drawFilledPath(xPts, yPts, null, null);
Upvotes: 1
Reputation: 9872
The drawLine()
method will draw a straight line in any direction, including on a "slant." If you want the line to be thicker than a single pixel, then simply call drawLine()
multiple times, adjusting the start and end points. So for example, to draw a horizontal line that is two pixels thick:
g.drawLine(10, 10, 110, 10);
g.drawLine(10, 11, 110, 11);
Upvotes: 2