Comments on: Enable/disable entire figure window https://undocumentedmatlab.com/blog_old/disable-entire-figure-window Charting Matlab's unsupported hidden underbelly Thu, 07 Sep 2023 16:43:44 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: jagadeeshhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-457516 Wed, 16 Jan 2019 03:29:50 +0000 https://undocumentedmatlab.com/?p=2089#comment-457516 Dear Yair,

Thanks for your inputs.

Our current plan is to bring a university-student into our team for internship to study the way for – what we are expected.
Also, we want the student to examine Java-events to be used for this purpose.

Parallely, we will get in touch with you for the consulting-proposal- at some suitable time soon

best regards
Jagadeesh K

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-457235 Thu, 10 Jan 2019 08:48:26 +0000 https://undocumentedmatlab.com/?p=2089#comment-457235 Matlab figures were never meant to be reparented in this way, and there are apparently many dependencies in the built-in interaction mechanisms that break because of this. If you would like my assistance in researching this area in the hope of finding a solution, then contact me offline (altmany at gmail) for a consulting proposal. Note that I cannot promise in advance that I will be able to find a solution, because this is an area nobody has previously investigated (AFAIK).

]]>
By: Jagadeeshhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-457234 Thu, 10 Jan 2019 08:42:25 +0000 https://undocumentedmatlab.com/?p=2089#comment-457234 Heah Yair,

I could successfully embed the Matlab-Figure into Swing’s JFrame using the JLayeredPane. Thanks for this information

After getting the Figure in the Swing-JFrame: Zoom-in and Zoom-out is working sexy but Pan, Datacursor and Rotate is not working at all. Even if this works, it is inconsistent.

any possible reasons, why its so ?

Thanks once again, your input helped us a lot
regards
Jagadeesh K

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-457192 Wed, 09 Jan 2019 10:32:49 +0000 https://undocumentedmatlab.com/?p=2089#comment-457192 Instead of the ContentPane, I suggest that you try to reparent LayeredPane or RootPane, which are higher-up in the FigureFrame’s hierarchy.

Also, it would be easier for you to debug if you reparent into a Swing JFrame rather than JavaFX – this way you can more-easily debug the Swing reparenting aspects (which are not trivial, due to the way that Matlab’s menubar and toolbar interact with the figure contents), separately from the JavaFX aspects.

Finally, you may find the following relevant/interesting:

]]>
By: Jagadeeshhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-457181 Wed, 09 Jan 2019 03:49:29 +0000 https://undocumentedmatlab.com/?p=2089#comment-457181 Hi Yair,

these details and articles are excellent.

I want to bring the Matlab-Figure( compiled with Javabuilder) on JavaFX-Scene

here are the details,
jf.fHG2Client.getWindow will return you – com.mathworks.hg.peer.FigureFrameProxy$FigureFrame and
get(jw,'ContentPane') will return you – javax.swing.JPanel

I can convert this JPanel to JavaFX using SwingNode.
but, when i put this JPanel on a JavaFX scene i only get a blank JPanel without the Menubar, Axes and other components.
what am i missing ?

]]>
By: Jagadeeshhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-457164 Tue, 08 Jan 2019 15:06:47 +0000 https://undocumentedmatlab.com/?p=2089#comment-457164 Hi Yair,

these details are Excellent.

I need to embed a Matlab-Figure inside a JavaFX-scene.

I know that – get(f,’Javaframe’) returns you the com.mathworks.hg.peer.HG2FigurePeer object.

How can i add “com.mathworks.hg.peer.HG2FigurePeer object” into Javafx – scene ?

]]>
By: Ashwanth Narayanaswamyhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-414010 Mon, 25 Sep 2017 17:27:57 +0000 https://undocumentedmatlab.com/?p=2089#comment-414010 Thank you Yair!! I appreciate it!!

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-413944 Sun, 24 Sep 2017 07:17:15 +0000 https://undocumentedmatlab.com/?p=2089#comment-413944 @Nalla – I believe that a simple call to drawnow; pause(0.1) after your questdlg will solve the problem. See here: https://undocumentedmatlab.com/blog/solving-a-matlab-hang-problem

]]>
By: Nalla Thambihttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-413868 Thu, 21 Sep 2017 21:05:18 +0000 https://undocumentedmatlab.com/?p=2089#comment-413868 Hello Yair,

Thanks for the code enableDisableFig.m

I use this to disable the first MATLAB GUI window(figure),from which a second MATLAB GUI window is opened
once the first window is disabled, inputs are transferred to the second window
some processing is done in the second window
the outputs are passed onto the first window
the second window is then closed (deleted)
at this point the first window is enabled again

All is well, until I introduced a questdlg in the second window
when user presses a button in second window, a question dialgue pops up, and some processing happens, according to user choices
after the questdlg pops up, it seems to trigger something and the first window gets enabled for some reason, even before i use the enabledisable.m function to enable it again
(the first window gets enabled , even while the second window is still alive-after the questdlg popsup)

Can you please comment on what I am doing wrong?

The code is as follows:

hFig = findobj('Name','first_window');
enableDisableFig(hFig, 'off');
 
handles.outputs=second_window(handles.inputs);
 
hf = findobj('Name','second_window');
delete(hf);
 
enableDisableFig(hFig, 'on');

I use MATLAB R2016b

Thanks

P.s:
I also tested this a follows
1. Open a MATLAB GUI figure
2. disable it using enabledisablefig.m
3. double check if window is disabled
3. now just type in a questdlg command in the MATLAB command window and respond to it
4. now check if the window is still disabled( now, i find that the window has gotten enabled for some reason)

Can you Please help, thanks

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-337835 Mon, 17 Nov 2014 15:40:34 +0000 https://undocumentedmatlab.com/?p=2089#comment-337835 @Kris – I already answered this above.

jFrame = get(handle(hFig), 'JavaFrame');
jFrame.fHG2Client.getWindow.setEnabled(flag);
]]>
By: Kris Janssenhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-337830 Mon, 17 Nov 2014 15:20:20 +0000 https://undocumentedmatlab.com/?p=2089#comment-337830 Hello Yair,

I recently took Matlab 2014b for a spin and browsing the Matlab Jar files I found that most of the stuff in com.mathworks.hg.peer is now private or protected.

Particularly, fFigureClient is no longer accessible…

Lacking a clear overview of the internal structure of Matlab I was wondering if you are aware of any alternatives to achieving enable/disable functionality for whole figures.

Cheers,

Kris

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-327916 Tue, 15 Jul 2014 12:30:27 +0000 https://undocumentedmatlab.com/?p=2089#comment-327916 You’d need to disable the individual controls. Disabling the content pane, root pane, or any other internal panel does not work, AFAIK.

]]>
By: Moritzhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-327910 Tue, 15 Jul 2014 10:31:12 +0000 https://undocumentedmatlab.com/?p=2089#comment-327910 Hi Yair,
I have a startup GUI, that opens other GUIs by clicking on buttons. If they are opened the first time, the user is able to enter data in uicontrols etc. By closing, I just set visible off and if the user opens it again, it will be set on. So the data remain in the textfields, tables,… If it is reopened, the user should not be able to change the data.

Therefor I used this code to lock it, after making it visible:

jFrame = get(handles.esr_basic, 'JavaFrame');
jWindow = jFrame.fHG1Client.getWindow;
set(handle(jWindow),'Enabled',false);

Problem: The GUI appears, is locked and can’t be closed again.

Afterwards I just tried to lock the content area:

jFrame = get(handles.esr_basic, 'JavaFrame');
jFrame.getFigurePanelContainer.setEnabled(false);

Problem: Nothing happened. Uicontrols can be used like before. Just the warning, that the property will be obsoleted in future release appears, no error.
In this special case, there are radio buttons in button groups. A simple push button outside the button groups is also still working.
Did I do something wrong? Do you know a solution?
Thanks!

]]>
By: ehsanhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-325537 Fri, 30 May 2014 18:30:08 +0000 https://undocumentedmatlab.com/?p=2089#comment-325537 Yair Altman and Ian Andolina, u both are absolutely my saviors.
thx a lot.
it really work :)

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-320180 Sun, 23 Mar 2014 19:03:57 +0000 https://undocumentedmatlab.com/?p=2089#comment-320180 @John – both R2013a and R2013b are covered by this code, why do you ask? have you seen otherwise?

]]>
By: Johnhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-320178 Sun, 23 Mar 2014 18:59:19 +0000 https://undocumentedmatlab.com/?p=2089#comment-320178 What about R2013?

jFrame = get(handle(hFig), 'JavaFrame');
try
    % This works up to R2011a
    jWindow = jFrame.fFigureClient.getWindow;
catch
    try
        % This works from R2008b and up, up to HG2
        jWindow = jFrame.fHG1Client.getWindow;
    catch
        % This works in HG2
        jWindow = jFrame.fHG2Client.getWindow;
    end
end
]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-295529 Fri, 15 Nov 2013 01:36:18 +0000 https://undocumentedmatlab.com/?p=2089#comment-295529 @Charlie – the components may appear enabled, but if you try to click on them (or anywhere in the window) you will see that the entire window is disabled.

]]>
By: Charliehttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-295526 Fri, 15 Nov 2013 01:29:45 +0000 https://undocumentedmatlab.com/?p=2089#comment-295526 Yair, I’m using your code in my GUI in Matlab R2013a and it seems it doesn’t work. The code doesn’t give any error, but all the components are still enabled except a popupmenu.

Get javaframe gives this result:

com.mathworks.hg.peer.HG1FigurePeer@37953f1e

Then, jWindow is:

com.mathworks.hg.peer.FigureFrameProxy$FigureFrame[fClientProxyFrame,296,107,772×504,invalid,layout=java.awt.BorderLayout,title=Módulo de Movimientos,normal,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=com.mathworks.widgets.desk.DTRootPane[,2,35,768×465,layout=com.mathworks.widgets.desk.DTRootPane$DTRootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=449,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]

Do you know where could be the problem?

Best regards,

Charlie

]]>
By: Matthiashttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-225728 Tue, 16 Jul 2013 08:46:30 +0000 https://undocumentedmatlab.com/?p=2089#comment-225728 @Yair – Thank you very much. It worked liked a charm.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/disable-entire-figure-window#comment-225721 Tue, 16 Jul 2013 08:31:10 +0000 https://undocumentedmatlab.com/?p=2089#comment-225721 @Matthias – it looks like you’re using a GUIDE-generated GUI. Try placing your JavaFrame code in the figure’s OutputFcn, not its CreateFcn, since the Java peers are not instantiated until the figure becomes visible.

]]>