Tue Nov 11, 2008 8:50 pm
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.Line2D;
public class DrawTriangleUsingLine2D extends JApplet {
public void init() {
setBackground(Color.lightGray);
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(Color.red);
g2d.draw(new Line2D.Double(50,150,150,150 ));
g2d.draw(new Line2D.Double(50,50,150,150 ));
g2d.draw(new Line2D.Double(50,50,50,150 ));
}
public static void main(String s[]) {
JFrame frame = new JFrame("Show Triangle");
JApplet applet = new DrawTriangleUsingLine2D();
frame.getContentPane().add("Center", applet);
applet.init();
frame.setSize(300, 250);
frame.show();
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.