I am writing a program that, when you click the mouse, it types a circle. Below is the code that I have written so far.
import java.awt.*; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.event.*; import java.awt.geom.*; public class test extends JFrame implements ActionListener, MouseListener { Shape circle = new Ellipse2D.Float(10, 10, 10, 10); public test () { setSize(250,150); addMouseListener(this); } public static void main(String[] args) {
The code is a 400X400 jframe, when you click on it, a circle opens in half a second. The problem is that when I release the mouse, the circle disappears. why?
source share