https://docs.oracle.com/javase/tutorial/uiswing/painting/closer.html
The paintComponent method is where all of your custom painting takes place.
In most cases the object that is actually received by this method will be an instance of java.awt.Graphics2D (a Graphics subclass), which provides support for sophisticated 2D graphics rendering.
The invocation of super.paintComponent(g) passes the graphics context off to the component's UI delegate, which paints the panel's background.
Whenever a MouseEvent received, it is forwarded to the moveSquare method, which updates the square's coordinates and repaints the component in an intelligent manner.
repaint method. This method is defined by java.awt.Component and is the mechanism that allows you to programatically repaint the surface of any given component. It has a no-arg version (which repaints the entire component)
'이제는 사용하지 않는 공부방 > Java' 카테고리의 다른 글
[uml] provided interface, required interface (0) | 2020.03.25 |
---|---|
추상클래스와 인터페이스 (0) | 2020.03.25 |
java 이중버퍼링 (0) | 2020.03.13 |
java static 변수 (0) | 2020.03.13 |
환경변수설정 (0) | 2020.03.13 |