java drawing a circle when mouse clicked

前端 未结 2 814
不知归路
不知归路 2021-01-18 04:57

i am writing a program that when the mouse is clicked, a circle will be drawn. The below code i\'ve wrote so far.

import java.awt.*;
import javax.swing.*;
i         


        
2条回答
  •  遇见更好的自我
    2021-01-18 05:36

    When you call repaint(), the component gets painted again from scratch. You're circle is wiped away. You will want to override paintComponent(Graphics) which is called every time the component is painted.

提交回复
热议问题