Skip to content

Instantly share code, notes, and snippets.

@MinSomai
Created February 22, 2020 17:51
Show Gist options
  • Save MinSomai/5e93ae5225d6fd262086fe1a5a14190d to your computer and use it in GitHub Desktop.
Save MinSomai/5e93ae5225d6fd262086fe1a5a14190d to your computer and use it in GitHub Desktop.
package hw;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Translation13 extends JPanel{
int x1=150, y1=150, x2=130, y2=130, tx=150, ty=1, px1, px2,py1, py2;
public Translation13() {
px1=x1+tx;
px2=x2+tx;
py1=y1+ty;
py2=y2+ty;
}
public void paint(Graphics g) {
g.drawLine(x1,y1,x2,y2);
g.drawLine(px1,py1,px2,py2);
}
public static void main(String[] args) {
JFrame frame =new JFrame();
frame.setTitle("Translation Example (Min): ");
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setContentPane(new Translation13());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment