Skip to content

Instantly share code, notes, and snippets.

@MinSomai
Created February 22, 2020 18:04
Show Gist options
  • Save MinSomai/f2c9bf8e577ffaa22cbe3ffed449a9cb to your computer and use it in GitHub Desktop.
Save MinSomai/f2c9bf8e577ffaa22cbe3ffed449a9cb to your computer and use it in GitHub Desktop.
package hw;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.JFrame;
public class ReflectionX13 extends JPanel {
int x1=100,y1=100,x2=290,y2=280,px1,px2,py1,py2;
public ReflectionX13() {
px1=y1;
px2=y2;
py1=x1;
py2=x2;
}
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("Reflection on X-axis: ");
frame.setVisible(true);
frame.setSize(500,500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new ReflectionX13());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment