I am developing a Java Swing-based application with different perspectives. For the "main menu" perspective I do not want the window (JFrame) to be decorated, while in other perspective I do want the window to be decorated. In other words, I need want to change the decoration attribute dynamically.
I have tried to use setUndecorated(false) and setUndecorated(true), but I seems I can only set this once, before actually showing the window.
Is there a way to achieve this?
From the javadoc:
Therefore, once the
JFrameis packed and/or displayed, you can no longer change that value. If you want to change theundecoratedstate of aJFrameyou will need todispose()it first, then change the state and eventually make it visible again.