new BasicStroke(float width) : BasicStroke « java.awt « Java by API






new BasicStroke(float width)


import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

import javax.swing.JComponent;
import javax.swing.JFrame;

public class MainClass{
  public static void main(String[] args) {
    JFrame jf = new JFrame("Demo");
    Container cp = jf.getContentPane();
    MyCanvas tl = new MyCanvas();
    cp.add(tl);
    jf.setSize(300, 200);
    jf.setVisible(true);
  }
}

class MyCanvas extends JComponent {
  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D)g;
    
    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(8));
    g2.draw(new Ellipse2D.Double(20,20, 50, 50));

  }
}

           
       








Related examples in the same category

1.BasicStroke.CAP_BUTT
2.BasicStroke.CAP_ROUND
3.BasicStroke.CAP_SQUARE
4.BasicStroke.JOIN_BEVEL
5.BasicStroke.JOIN_MITER
6.BasicStroke.JOIN_ROUND
7.new BasicStroke(float width, int cap, int join, float miterlimit, float[] dash, float dash_phase)