f



How to notify Matlab about Java object change in Matlab Java Interface?

Hello,

Does anybody has any idea how to update Matlab function about Java
object change ?

It could be done by polling:

while JavaObj.getValue()=='not done yet'
  pause(1);
end

But polling is evil. There should be more elegant way to do this
job ...

I've checked 'Matlab Java Interface' docs :
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f6671.html
, but found nothing on the subject :(


Thanks in advance for your help,


0
stasgold (23)
4/21/2009 2:26:35 PM
comp.soft-sys.matlab 211266 articles. 23 followers. lunamoonmoon (257) is leader. Post Follow

6 Replies
1305 Views

Similar Articles

[PageSpeed] 27

Could you use javacomponent to set up the object, and set a callback to repond to the changed value?
0
ku.ca.lck (151)
4/21/2009 2:44:02 PM
On Apr 21, 5:44=A0pm, "Malcolm Lidierth" <ku.ca....@htreidil.mloclam>
wrote:
> Could you use javacomponent to set up the object, and set a callback to r=
espond to the changed value?

Hi Malcolm Lidierth,

I had no clue about javacomponent  existence (no wonder it's
undocumented ), thanks for providing the feedback :)

It looks I will use it in the case I won't find a way to set a Matlab
callback from standard java JFrame container ( instead of embedding
swing components into Matlab figure )

I've checked out a possible usage of "waitfor" for this purpose :

waitfor(JavaObj,some_field,value)

It doesn't seem to work :(

Maybe someone of matlab developers would be so nice to share with us
his thoughts on this subject ... :)
0
stasgold (23)
4/21/2009 3:42:15 PM
If you are using swing components, you might take a look at Yair Altman's uicomponent or my own jcontrol class on the FEX. 
http://www.mathworks.com/matlabcentral/fileexchange/15580
Both provide access to the MATLAB container and the underlying swing component through a single object.
A MATLAB figure can not parent a JFrame to the best of my knowledge but you can build GUIs in e.g. a JPanel contained in an ML figure easily enough.
0
ku.ca.lck (151)
4/21/2009 4:13:02 PM
> It looks I will use it in the case I won't find a way to set a Matlab
> callback from standard java JFrame container ( instead of embedding
> swing components into Matlab figure )

You can set Matlab callbacks for any Java object (including your JFrame) as follows:

hObject = handle(jObject,'callbackProperties');  % jObject is your java object reference
set(hObject,'WidowIconifiedCallback',@myMatlabFcn);  % for example

To see the list of all supported callbacks etc., you can use my UIINSPECT (http://www.mathworks.com/matlabcentral/fileexchange/17935 ) or FINDJOBJ (http://www.mathworks.com/matlabcentral/fileexchange/14317 ) submissions on the File Exchange.

Yair Altman
http://UndocumentedMatlab.com 
 
0
altmanyDEL (1141)
4/21/2009 4:59:02 PM
On Apr 21, 7:59=A0pm, "Yair Altman" <altmany...@gmailDEL.comDEL> wrote:
> > It looks I will use it in the case I won't find a way to set a Matlab
> > callback from standard java JFrame container ( instead of embedding
> > swing components into Matlab figure )
>
> You can set Matlab callbacks for any Java object (including your JFrame) =
as follows:
>
> hObject =3D handle(jObject,'callbackProperties'); =A0% jObject is your ja=
va object reference
> set(hObject,'WidowIconifiedCallback',@myMatlabFcn); =A0% for example
>
> To see the list of all supported callbacks etc., you can use my UIINSPECT=
 (http://www.mathworks.com/matlabcentral/fileexchange/17935) or FINDJOBJ (h=
ttp://www.mathworks.com/matlabcentral/fileexchange/14317) submissions on th=
e File Exchange.
>
> Yair Altmanhttp://UndocumentedMatlab.com

Thanks Yair,

Your post helped me big way. I just wonder how your tools are not yet
a part of standard Matlab distribution ...

UndocumentedMatlab.com is bookmarked as well :) Keep up the good work.
0
stasgold (23)
4/22/2009 7:43:09 AM
For those interested, I posted an article about undocumented Matlab-Java callbacks here: http://undocumentedmatlab.com/blog/uicontrol-callbacks/

Yair Altman
http://UndocumentedMatlab.com
0
altmanyDEL (1141)
7/28/2009 9:47:03 AM
Reply: