Total members 9951 | Gratitudes |It is currently Sat Feb 11, 2012 10:04 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: Draw Triangle using Lines
PostPosted: Tue Nov 11, 2008 8:50 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2103
Location: Earth
Has thanked: 39 time
Have thanks: 56 time

Draw Triangle using Lines using java graphics
Code:
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();
  }
}


Attachments:
File comment: Draw Triangle in Java .
triangle.gif
triangle.gif [ 4.64 KiB | Viewed 11948 times ]

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )
TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 increase the number of bank lines by <br/>  HTML examples  msi_333  0
 Read an image bitmap (.bmp) file and draw it as texture  C++ openGL examples  msi_333  0
 Drawing a triangle with colors  C++ openGL examples  msi_333  0
 Java Programming Problem: Pascal's Triangle  Java  vikrantmalik  0
 i want to draw a circle on a image(any format bmp,jpeg etc.)  C#  amit4540  0

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team