Why not to draw directly inside JFrame [duplicate]

99封情书 提交于 2019-11-27 15:58:22
MadProgrammer

Three main reasons...

  1. Top level containers aren't double buffered, which cause flickering when the frame is repainted, yes, you can implement you're own double buffering, but...
  2. Painting inside a frame does not take into consideration the frames borders, meaning that it's possible to paint under them. Frame borders are also platform/look and feel specific, meaning that there sizes change
  3. In the case of Swing windows, there are components that already exist on the window, meaning that they paint over (or be painted over), in most cases, both (because of the optimised painting engine in Swing), making it difficult to produce a reasonable result

For point #2, frame decorations are painted WITHIN the "window" bounds, not outside them

Take a look at...

for more details

Make the time to read through Painting in AWT and Swing and Performing Custom Painting for more details

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!