Tue Apr 17, 2007 2:43 pm
/*
* Translation.java
* Created on April 17, 2007, 3:32 PM
*/
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
/**
*
*/
public class Translation extends JFrame{
private int width=400;
private int height=400;
private int x1=-100;
private int y1=-100;
private int x2=100;
private int y2=100;
private int dx=20;
private int dy=20;
public Translation() {
setTitle("Line Translation");
setSize(width,height);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public void paint(Graphics g) {
g.fillRect(0,0,500,500);
g.setColor(Color.RED);
g.drawLine(x1+200,200-y1,x2+200,200-y2);
g.setColor(Color.GREEN);
g.drawLine(x1+200+dx,200-y1+dy,x2+200+dx,200-y2+dy);
}
public static void main(String[] args) {
// TODO code application logic here
new Translation();
}
}
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.