Случайные круги JAVA

Я пытаюсь создать графический интерфейс, который будет принимать количество нарисованных кругов, и рисовать их в drawPanel со случайными местоположениями / размерами. На моем actionListener, когда я пытаюсь нарисовать круг, он дает мне красные линии на моем drawOval

1 класс:

 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.Graphics;
 import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.Random;
 import javax.swing.BorderFactory;
 import javax.swing.JButton;
 import javax.swing.JPanel;
 import javax.swing.JTextArea;

/**
 * 
 * @author Chris
 *
 */
 public class CirclesPanel extends JPanel{
 private JButton draw, clear;
 private JTextArea textArea;
 private JPanel panel, drawPanel, buttonPanel;
 private int count;

 /**constructor
* builds the frame
*/
 public CirclesPanel(){

//creates buttons and textArea
  draw = new JButton("Draw"); 
  clear = new JButton("Clear");
  textArea = new JTextArea(1,10);
  textArea.setBorder(BorderFactory.createTitledBorder("Circles"));

//creats panel
 JPanel panel = new JPanel();
 panel.setLayout(new BorderLayout());
 setPreferredSize(new Dimension(620, 425));
//creates subpanel drawPanel
 JPanel drawPanel = new JPanel();
 drawPanel.setPreferredSize(new Dimension(450,400));
 drawPanel.setBackground(Color.BLACK);
//creates subpanel buttonPanel
 JPanel buttonPanel = new JPanel();
 buttonPanel.setLayout(new GridLayout(3,1));
//adds all the content to the frame
 add(panel);
 add(buttonPanel, BorderLayout.WEST);
 add(drawPanel, BorderLayout.EAST);
 buttonPanel.add(textArea);
 buttonPanel.add(draw);
 buttonPanel.add(clear);
//reads if the draw button is clicked
 draw.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e)
    {
      count =Integer.parseInt(textArea.getText());//takes the count in
      repaint();//repaints the picture to add the circles
    }
 }); 
//reads if the clear button is clicked
 clear.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e)
            {
            count=0;//sets the count to 0 so nothing is painted
              repaint();//repaints the window
            }
         }); 



 }
/**Paint component
 * draws the random circles
 */
  public void paintComponent(Graphics g) {
 Random generator = new Random();
 int x, y, diameter;
 for(int i = 0; i < count; i++){ //loop that takes the count and does this "x" times
  g.setColor(Color.BLUE);//sets color to blue
  x = generator.nextInt(90);//random location for x
  y = generator.nextInt(90);//random location for y
  diameter = generator.nextInt(30);//random size
  g.fillOval(x, y, diameter, diameter);//draws the circle
    }
}
 }

2-й класс

import javax.swing.JFrame;


public class Circles { 
public static void main(String[]args){
JFrame frame = new JFrame("Cicles HW9");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

frame.getContentPane().add(new CirclesPanel());

frame.pack();
frame.setVisible(true);


}
}

Ответы на вопрос(2)

Ваш ответ на вопрос