How to add support for resizing when using an undecorated JFrame?

心已入冬 提交于 2019-11-29 04:09:46

As you said, you have a border on your root pane. As a consequence, there is at least one location (below the palce where your border is drawn) where your root pane is the upmost component. As a consequence, you can add it a mouse listener and a mouse motion listener.

When your root pane is clicked (and the mouse button is pressed), your mouse and motion listeners will inform you of the initial and actual mouse position. As a consequence, you can update your frame size of the offset between both values, making your frame resizable.

Resizing Components shows one way.

I found a nice method in RootPane that gave me this functionality, so now I only have to find out how to customize the titlebar and the buttons on it.

I added this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); in my constructor for UndecoratedFrame.

There is some more reading about this on Sexy Swing App – The Unified Toolbar and How to control window decorations

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