Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import java.awt.geom.*;
- import java.math.*;
- import java.lang.*;
- public class ForWhile extends Frame {
- public void paint(Graphics g) {
- Graphics2D graph = (Graphics2D)g;
- graph.setStroke(new BasicStroke(3.0f));
- graph.setColor(Color.black);
- double a = 100;
- double b =200;
- for(int i = 0 ; i<=10 ; i++)
- {
- double c = Math.random()*800;
- double d = Math.random()*800;
- Line2D line = new Line2D.Double(a,b,c,d);
- graph.draw(line);
- a = c;
- b = d;
- }
- }
- public static void main(String[] args) {
- Frame frame = new ForWhile();
- frame.addWindowListener(
- new WindowAdapter(){
- public void windowClosing(WindowEvent we){
- System.exit(0);
- }
- }
- );
- frame.setSize(1000, 1000);
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement