Drawing with Java
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class drawing extends JFrame
{
public drawing()
{
super(" Graphics 2D Shapes");
setBackground(Color.blue);
setSize(600,500);
setVisible(true);
}
public void paint(Graphics g)
{
//super.paint(g);
Graphics2D g2d=(Graphics2D)g;
//------------------Line---------------------------------------------------//
g2d.setPaint(Color.red);
g2d.setStroke(new BasicStroke(6.0f));
g2d.draw(new Line2D.Double(100,150,500,300));
}
public static void main(String args[])
{
drawing d=new drawing();
d.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Comments
Post a Comment