This section illustrates you how to show stroke with effect.
The interface Stroke gives the stylish way of representing the outlines. To show the effect, class GradientPaint is used which fills the specified figure in a color gradient pattern. The class Rectangle2D provides the rectangle figure.
Following code shows the simple rectangle filled with color gradient pattern:
Following code shows the stroke inside the rectangle:
| rectangle.setFrame(p + 90, q, width, height);
Following code strokes with gradient:
|rectangle.setFrame(p + 180, q, width, height);
The method setFrame() sets the size of the rectangle. The setPaint(gradientPaint) paints the rectangle in a gradient pattern. The method setStroke() sets the stroke settings for the Graphics2D context, when you draw the shape. The integer value passed into the constructor of class BasicStroke represents the thickness of the outline.
Here is the code of EffectsOfStroke.java
Output will be displayed as:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.