Created
February 22, 2020 17:51
-
-
Save MinSomai/5e93ae5225d6fd262086fe1a5a14190d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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