Wednesday, August 27, 2008

How to remove or disable the Minimize, Maximize and Close Button of JFrame?

Yesterday a friend question me how can i remove or disable the minimize, maximize and close buttons of frame? Here shows some possibilities that could be a solution.

  • The first alternative is use a JWindow instead of a JFrame which does not have those three buttons.
  • The second alternative could be use JInternalFrame instead of a JFrame.
  • The third alternative is use the setUndecorated() method to disable the decorations to this frame and later decorate with a dialog style. The only problem is that the close button don't remove so you must disable its function such as can see below



  • The last alternative could be disable the close and resizable buttons such as can see bellow.


I believe there are more solutions, but for me are the most easy and utils...