I was building a simplistic "game" as sort of tutorial into developing apps or such in java. My Main
class extends JFrame
. It was just moving a ball around the screen. After getting to the point where I can move the ball can move I started implementing collision with the boundaries of the window and spent several minutes trying to figure out why the only went some beyond the border on 3 sides and then far beyond the top before I realized that the boundaries were being obeyed but that they were the edges of the actual window, beyond the display area.
How would I set up the Main
class so that the boundaries are the visible area? Would it extend a different class? And then what it be inside of something else?
paintComponent(...)
method, super.paintComponent(g)
inside the override.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.