Search code examples
javaswingjdialogjprogressbar

JDialog decorated true but without close button


Okay, researching I saw a lot of posts regarding to the topic "hide close button from dialogs" but none of them solved my problem.The thing is I have this Dialog:

enter image description here

which I would like to keep the decoration (borders, transparency and etc) but I would like to hide or remove the close button component cos I will handle this with the cancel button.

If I use

setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.NONE);

the result I will get is

enter image description here

which for me its completely terrible(not at all here since nothings on background)...so I ask: is there another way to handle this problem with dialog or setUndecorated and getRootPane are absolute? Futher suggestions are very welcome. Thanks in advance.


Solution

  • You cannot remove the "X" button without messing with UI code (low level LAF or even native api), I dont know is it worth of the effort. However, if you REALLY REAAAALLLLLY need such functionality (and you will get lots of money for that;P) you can always write native code that would hide the X button (yes that is totally possible), but again, that is not worth of your time :)