1

Possible Duplicate:
How to disable (or hide) the close (x) button on a JFrame?

I want the frame to have a deactivated close button, but I don't want to do frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); nor frame.setUndecorated(true).

I want the frame to appear but the close button should look inactive/disabled.

If we cant achieve this in JFrame is there a way to do this? You suggestions will be of great help.

Community
  • 1
  • 1
Buggs
  • 21
  • 1
  • 1
  • 4

2 Answers2

5

I think the best answer is that it is not possible.

I would choose the DO_NOTHING_ON_CLOSE and override the windowClosing event in its WindowAdapter as the best option.

frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
  public void windowClosing(WindowEvent e) {
    // do whatever else
  }
});
Dan D.
  • 32,246
  • 5
  • 63
  • 79
  • Is there any other Java GUi which allows this capability. I see applications like skype disables the close button on their log in window. How do they achieve that, Any idea. – Buggs Sep 09 '12 at 22:48
3

This bug report says that it is not possible , though it is a old link but it is not probably added in jdk yet :(

MD. Sahib Bin Mahboob
  • 20,246
  • 2
  • 23
  • 45