APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

disable x button of applet post and replies

Return to the disable x button of applet thread
Login to post to this thread

How to diasble x button(close)
Apostolos Michaloudis
28 Posts

Hello!
Is there a way to disable the red x button which closes the standalone applet window?
I need something like DO_NOTHING_ON_CLOSE
How can I access the main frame's code so I can do this?
Do I have to create the jar file and then open it with a txt reader in order to change this parameter?I want the user to close the frame by clicking a Exit button in the simulation. Will System.exit() work for this?

Also, would you consider adding this feature at frame's properties when we double click on it?


Replies to How to diasble x button(close)

Re: How to diasble x button(close) -
Francisco Esquembre
237 Posts

Add this to an Initialization page.

if (_view.drawingFrame instanceof JFrame) ((JFrame)_view.drawingFrame).setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);


The reason for the check is that the frame may be something different if the simulation runs as an applet.

Paco



Re: Re: How to diasble x button(close) -
Apostolos Michaloudis
28 Posts

Thank you mr. Esquembre, you always help us a lot!



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book