Resizing JFrame in one dimension

后端 未结 1 395
深忆病人
深忆病人 2020-12-21 03:17

I am trying to re-size my JFrame in only one dimension (width in this case) and I found this question JFrame re-sizable height ONLY which gave me a good answer for doing so;

相关标签:
1条回答
  • 2020-12-21 03:36

    The short answer is you can't. In Swing all events go to your Java code, then update the on screen graphics... except for resizing windows. The window itself is a native control. Events go to the window first, then to the Java side. Your original code works on the Java side so the window has already resized by the time you size it back. That's what causes the glitchy behavior.

    The only way around this (short of digging into C++ native code) is to disable native window decorations and render your own resize handles. Then your code would receive the resize events before the native window does and the glitches would go away. Not a trivial amount of work, but it might be feasible depending on your use case.

    0 讨论(0)
提交回复
热议问题