Swing - setResizable(true) make JFrame title bar higher and window size smaller

为君一笑 提交于 2019-12-04 19:26:33

After all it is a Look & Feel problem......

If we use Java default Metal look and feel, and set setDefaultLookAndFeelDecorated(true) before creating both frames, the border/insets of Java default look & feel style will be painted and visible, thus two JFrames have same width and height.

I have played with other L&F and find that javax.swing.plaf.nimbus.NimbusLookAndFeel, com.sun.java.swing.plaf.windows.WindowsLookAndFeel and com.sun.java.swing.plaf.motif.MotifLookAndFeel haven't implemented this extra dragging handler, maybe for aesthetic reasons. (I really doubt that why Java default style wanted to paint this handler. I personally don't think it's imprescindible. I think ppl implementing the other L&F also wanted to avoid it so they came up with a usable but ugly solution. )

This GIF shows you how the default Metal L&F paints the "handle" of resizing in both frames:

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