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.

Problems with the windows post and replies

Return to the Problems with the windows thread
Login to post to this thread

Problems with the windows
Manuel M.
6 Posts

Hello everyone!
I'm learning to use EJS and I have difficulty in showing a new window when a button is pressed and I don't know if it is possible.

I would like to know if there is some method to show a new window with the button action because I need a window to configure some settings and this windows should appear when the button is pressed.

I could see the method "_view.alert()" that show a window with a message and it would be similar but with buttons instead of a message.

Thanks for your help and sorry for my English :)

Manuel.


Replies to Problems with the windows

Re: Problems with the windows -
Francisco Esquembre
237 Posts

Hello Manuel,

I understand that you are using the Java favor of EjsS.

1.- Create a Dialog and place anything (other view elements) in it, according to your needs.

2.- Create a boolean variable called showDialog (or similar) and set its initial value to false.

3.- Link this boolean variable to the Visible property of the Dialog. (The dialog will not be visible.)

4.- Add a button to your main window with the Action:
  showDialog = true;

That is all. Changing the value of the shoDialog boolean shows/hides the dialog. Closing the Dialog (when visible) sets the boolean to false.

Paco



Re: Re: Problems with the windows -
Manuel M.
6 Posts

Hello Paco,

Many thanks for your help.

Yes, I'm using the Java favor of EjsS and I tried doing the steps of your post and it looks easy but it doesn't work for me.  My problem is that when I press the button I don't see the window but it appear when I close the program.

I tried setting the  'immediate' parameter of the button with the true value but this doesn't work either. What could I do? Because I think this method should work but maybe I have forgot something.

Thanks again for your help and best regards,
Manuel.

Post edited April 17, 2015 at 7:49 AM EST.



Re: Re: Re: Problems with the windows -
Francisco Esquembre
237 Posts

Hi again,

See attached example. It dos nothing, but exemplifies what (I think) you want to do.

Look also at the example MassAndSprig included with EjsS. There is a checkbox that shows/hides the plotting panel dialog.

Paco

Attached File: ejs_src_ShowHideDialog.zip



Re: Re: Re: Re: Problems with the windows -
Manuel M.
6 Posts

Hi Paco,

Many thanks for your help, It works perfectly.

Best regards,
Manuel.



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