Write a application that simulates a screen saver. The application should randomly draw lines using method drawLine of class Graphics. After drawing 100 lines, the application should clear itself and start drawing lines again. To allow the program to draw continuously, place a call to repaint as the last line in method paint.  ( File must be save as: Assignmen11.java)

import java.util.Random;
import java.awt.*;//Graphics;
//import java.awt.Color;
import javax.swing.*;//JPanel;
//import javax.swing.JFrame;


class Assignment extends JPanel
{

            private final int  A=999999;

            public void paintComponent(Graphics g)
            {
                        super.paintComponent(g);
                        Random r=new Random();

                        int w,x,y,z;
                        for(int i=0; i<100; i++)
                        {
                                    g.setColor(new Color(r.nextInt(256),r.nextInt(256),r.nextInt(256)));

                                    w=r.nextInt(400);
                                    x=r.nextInt(400);
                                    y=r.nextInt(400);
                                    z=r.nextInt(400);
                                    g.drawLine(w,x,y,z);


                                    for(int j=0; j<A; j++);

                        }
                        repaint();

            }
}


public class Assignment11
{
            public static void main(String args[])
            {
                        JFrame frame=new JFrame("Drawing lines.....");
                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                        //RandomLines randomLines=new RandomLines();
                        Assignment sc=new Assignment();

                        frame.add(sc);
                        frame.setSize(400,400);
                        frame.setVisible(true);
            }
}


 ////////////////////////////////////////////
Copy & paste this code in your Textpad & run, then you will get output.......
If you have any problem please comment below.........