Java graphic image

こ雲淡風輕ζ 提交于 2019-12-02 12:59:04
MadProgrammer

If painting directly to the top level container (JFrame), then the coordinate space will be wrong, the content pane is actually offset, taking into account the frame's border and menu bar.

This will occur if you override any of the frame's paint methods OR use the getGraphics method.

Create a custom component (extending from something like JPanel) and override it's paintComponent method and render the image and rectangle directly to it. The coordinate space will then be correct (top, left corner will be 0x0)

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