Howdy. 


import java.awt.Graphics; 
import java.awt.Color; 

public class Circle {
  int x, y, r; 
  Color c; 
  public Circle(int x, int y, int r, Color c) {
    this.x = x; 
    this.y = y;
    this.r = r;
    this.c = c; 
  }
  public void draw(Graphics g) {
    g.setColor(this.c); 
    g.fillOval(this.x, this.y, this.r, this.r); 
    g.setColor(Color.BLACK); 
    g.drawOval(this.x, this.y, this.r, this.r); 
  }
}

--

import javax.swing.JComponent; 
import java.awt.Graphics;
import java.util.ArrayList;
import java.awt.Color; 

public class Screen extends JComponent {
  
  ArrayList<Circle> circles = new ArrayList<Circle>(); 
  
  public Screen(int howMany) {
    for (int i = 0; i < howMany; i++) {
      this.circles.add( new Circle((int)(Math.random() * 250 + 50),
                                   (int)(Math.random() * 250 + 50),
                                   (int)(Math.random() * 50 + 30),
                                   new Color((float)(Math.random() * 0.5 + 0.5), 
                                             (float)(Math.random() * 0.5 + 0.5),
                                             (float)(Math.random() * 0.5 + 0.5))) ); 
    }
  }
  
  public void paintComponent(Graphics g) {
    for (Circle c : this.circles) {
      c.draw(g);  
    }
  }
}

--

import javax.swing.JFrame; 

public class Lab11 {
  public static void main(String[] args) {
    JFrame a = new JFrame(); 
    a.setVisible(true); 
    a.setSize(300, 400);
    a.add(new Screen(20)); 
  }
}

--

Lab 11 code is here:

import java.awt.Graphics; 
import java.awt.Color; 

public class Circle {
  int x, y, r; 
  Color c; 
  public Circle(int x, int y, int r, Color c) {
    this.x = x; 
    this.y = y;
    this.r = r;
    this.c = c; 
  }
  public void draw(Graphics g) {
    g.setColor(this.c); 
    g.fillOval(this.x, this.y, this.r, this.r); 
    g.setColor(Color.BLACK); 
    g.drawOval(this.x, this.y, this.r, this.r); 
  }
}

--

import javax.swing.JComponent; 
import java.awt.Graphics;
import java.util.ArrayList;
import java.awt.Color; 

public class Screen extends JComponent {
  
  ArrayList<Circle> circles = new ArrayList<Circle>(); 
  
  public Screen(int howMany) {
    for (int i = 0; i < howMany; i++) {
      this.circles.add( new Circle((int)(Math.random() * 250 + 50),
                                   (int)(Math.random() * 250 + 50),
                                   (int)(Math.random() * 50 + 30),
                                   new Color((float)(Math.random() * 0.5 + 0.5), 
                                             (float)(Math.random() * 0.5 + 0.5),
                                             (float)(Math.random() * 0.5 + 0.5))) ); 
    }
  }
  
  public void paintComponent(Graphics g) {
    for (Circle c : this.circles) {
      c.draw(g);  
    }
  }
}

--

import javax.swing.JFrame; 
import java.awt.event.MouseMotionListener; 
import java.awt.event.MouseEvent; 

public class Lab11 extends JFrame implements MouseMotionListener {
  public void mouseMoved(MouseEvent e) { 
    System.out.println("Mouse moved ( " + e.getX() + ", " + e.getY() + ") "); 
  } 
  int count; 
  public void mouseDragged(MouseEvent e) { 
    System.out.println("Mouse dragged... " + ++this.count);
  } 
  public Lab11() {
    this.setVisible(true); 
    this.setSize(300, 400);
    this.add(new Screen(6));   
    this.addMouseMotionListener( this );
  }
  public static void main(String[] args) {
    JFrame a = new Lab11(); 
    // 
  }
}

--

Young Hwan Namit Chase Dustin Michael Daohui Sai Nariman Ben 
Chun Mary Jiongran Sunghyun Grant Emma Yuying JeVante Stephen N
Zach Qi Murun Aarani Steben K Paul F Paul W everybody has 100