Index > 破線を描く方法(Java,Java2D)
Sat, October 14, 2006

{update:2006-10-20}

破線を描く方法(Java,Java2D)

Javaで破線を描画したい場合は、java.awt.BasicStrokeクラスを使用します。

static final private BasicStroke STROKE_DOTTED=
new BasicStroke(1,
    BasicStroke.CAP_BUTT,
    BasicStroke.JOIN_MITER,
    10.0f,
    new float[]{5f},
    0.0f);

public void paintComponent(Graphics g){
    Graphics2D g2=(Graphics2D)g;
    g2.setStroke(STROKE_DOTTED);
    g2.draw(new Line2D.Float(0,0,100,100));
}
 Twitter
follow me on Twitter
 Categories