mithun1538
mithun1538

Reputation: 1487

How to display a new frame in an an applet?

I have an applet. In this I have a JLabel component. When the user clicks this label, a new JFrame component gets displayed. I want to set the value of setDefaultCloseOperation() for this frame as JFrame.EXIT_ON_CLOSE. However, I get a SecurityException if I do that. I read the documentation of JFrame.EXIT_ON_CLOSE and its written that :

The exit application default window close operation. If a window has this set as the close operation and is closed in an applet, a SecurityException may be thrown. It is recommended you only use this in an application.

What I understood from the above is that if a frame is closed without specifying default close operation, the frame is only hidden. I want to close the frame when the user tries to close it, and not hide the frame. Is this possible?

Upvotes: 0

Views: 556

Answers (1)

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103155

You are not allowed to exit the application in an applet, Rather you can use DISPOSE_ON_CLOSE which removes the JFrame completely.

Upvotes: 2

Related Questions