// DDeleven21.java screensaver drawing lines
// using timer in swing

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class DDeleven21 extends JFrame implements ActionListener {
   private String s = "Using drawString!";
  public DDeleven21() {
  super("drawing lines " );
 Timer timer= new Timer(1000,this);
  timer.start(); 
  setSize( 400,165 );
  show();
}

public void actionPerformed( ActionEvent e){
   repaint(); }

public void paint (Graphics g ) {
super.paint(g );
  g.setColor( Color.red );
  g.drawLine(5,30,350,30 );
for (int i=0;i<100;i++) {
int x1= (int) (Math.random() *400);
int x2= (int) (Math.random() *400);
int y1=(int) (Math.random() *165);
int y2 = (int) (Math.random() *165);
g.drawLine(x1,y1,x2,y2); }// end of for i loop
//super.repaint(); //no problem in linux
// windows mouse had problem closing the JFrame

//super.setBackground(Color.yellow); changed background to yellow  

}

public static void main( String args[] ) {
  DDeleven21 app = new DDeleven21();
  app.addWindowListener(
     new WindowAdapter() {
      public void windowClosing(WindowEvent e )
    { System.exit( 0 ); }
    
  }
  );
 }
}



       
