Comments on: Matlab-Java interface using a static control https://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control Charting Matlab's unsupported hidden underbelly Thu, 02 May 2024 08:00:01 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-389260 Mon, 26 Sep 2016 10:44:13 +0000 https://undocumentedmatlab.com/?p=1917#comment-389260 @Tom – you are correct. This was simply a typo (jButton instead of hButton). I corrected the main text accordingly.

]]>
By: Tomhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-389257 Mon, 26 Sep 2016 10:12:36 +0000 https://undocumentedmatlab.com/?p=1917#comment-389257 Why you getting a handle if you don´t use it?

% Assign a Matlab callback
hButton = handle(jButton, 'CallbackProperties');
set(jButton, 'ActionPerformedCallback', @myCallback);
]]>
By: Abdullahhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-346711 Sun, 15 Mar 2015 23:46:26 +0000 https://undocumentedmatlab.com/?p=1917#comment-346711 So, I am trying the following:

I added a listener to a Simulink block.

When trying to execute a public function of my JAR file within the listener, I get an error.

I tried to use a timer to see if that would solve the issue. However, it didn’t work.

Any clues?

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-301312 Tue, 03 Dec 2013 16:53:15 +0000 https://undocumentedmatlab.com/?p=1917#comment-301312 @Jai – take a look at JMI: https://undocumentedmatlab.com/blog/jmi-java-to-matlab-interface/

]]>
By: Jai Nareshhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-301304 Tue, 03 Dec 2013 16:42:40 +0000 https://undocumentedmatlab.com/?p=1917#comment-301304 Hi,
I am trying to launch matlab model and control its execution through Java Interface. Please let me know if their are any ways to do this.

Any response will help.

Thanks,
jai Naresh

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-190276 Wed, 17 Apr 2013 10:01:03 +0000 https://undocumentedmatlab.com/?p=1917#comment-190276 @Nikhil – try adding C:\Users\x_shirod\.swt\lib\win32\x86_64\ to your librarypath.txt file:

edit('librarypath.txt')
]]>
By: nikhilhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-190269 Wed, 17 Apr 2013 09:45:40 +0000 https://undocumentedmatlab.com/?p=1917#comment-190269 Hello,

I am trying to open a UI created in Java SWT through Matlab.
But I am getting following error..

Java exception occurred:
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
	no swt-win32-3833 in java.library.path
	no swt-win32 in java.library.path
	Native Library C:\Users\x_shirod\.swt\lib\win32\x86_64\swt-win32-3833.dll already loaded in another classloader
	Can't load library: C:\Users\x_shirod\.swt\lib\win32\x86_64\swt-win32.dll

Can any one help me in this…

thanking you in advance.


Nikhil

]]>
By: George Brennanhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-116934 Fri, 26 Oct 2012 17:00:30 +0000 https://undocumentedmatlab.com/?p=1917#comment-116934 Well done.

I would add that as you are passing the Matlab instantiated app object around couldn’t you change the hMap to public and access it without the file I/O?

Although getters/setters are probably a more acceptable route.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-112874 Thu, 04 Oct 2012 18:16:48 +0000 https://undocumentedmatlab.com/?p=1917#comment-112874 @Rob – thanks for the correction. I fixed the article accordingly.

]]>
By: Rob Cranfillhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-112871 Thu, 04 Oct 2012 15:21:43 +0000 https://undocumentedmatlab.com/?p=1917#comment-112871 I think there’s a typo in the original code – in the 2nd code block, the first one after the heading “Using a callback switchyard function”. It says

get(triggerButton, 'ActionPerformedCallback',@TriggerCallback);

but I’m pretty sure that should be

set(triggerButton, 'ActionPerformedCallback',@TriggerCallback);  % set, not get

At least, the first one doesn’t work for me, and the second one does. (I’m using Matlab 2012a, but I don’t think that’s the issue.)

Thanks for lots of great Matlab help!

/rob

]]>
By: Donn Shullhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-54996 Thu, 25 Aug 2011 19:55:34 +0000 https://undocumentedmatlab.com/?p=1917#comment-54996 @Anubhav – This is a complicated area and you will have to do a lot of reasearch on your own to accomplish what you are looking for. The first thing to know is that the Simulink editor is not java based so none of the java techniques are going to be of use to you. Simulink to a certian extent is UDD based. There are two primary UDD packages you will need to study using the techniques from the series of articles on UDD. The first package is the ‘DAStudio’ package. The second is the ‘Simulink’ Package. DAStudio to a certian extent is the base package as it contains an object called DAStudio.Object which is the Superclass for Simulink.Object which in turn is the Superclass for most of the rest of the Simulink classes in the Simulink package. To a certian extent the uses for these packages can be divided as follows. Models are built from classes in the Simulink Package while Dialogs come from the DAStudio package. The parameter dialogs you are looking at are of tyoe DAStudio.Dialog. They do not generate any events on their own. They are however hierarchical children of DAStudio.ToolRoot. So in theory you can monitor an instance of DAStudio.ToolRoot for the events ‘ObjectsChildAdded’ and ‘ObjectChildRemoved’ using the methods in the Hiearchical Systems with UDD and UDD events posts.

Good Luck,

Donn

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-54851 Wed, 24 Aug 2011 07:30:56 +0000 https://undocumentedmatlab.com/?p=1917#comment-54851 @Anubhav – you can perhaps trap the dialog figure’s DeleteFcn callback.

]]>
By: Anubhav Jainhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-54842 Wed, 24 Aug 2011 04:34:31 +0000 https://undocumentedmatlab.com/?p=1917#comment-54842 Hi,
Thanks a lot for your immediate response.
Actually I wanted to get the name of an event associated with closing of function parameter dialog box for example if I change threshold value of a switch block and apply it then I should be able to listen to the event of closing of that parameter box. Can you please help me out with this.
Thanks & Regards
Anubhav Jain.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-54798 Tue, 23 Aug 2011 18:16:43 +0000 https://undocumentedmatlab.com/?p=1917#comment-54798 @Anubhav – you need to get the dialog handle before you can register any listener on it…

]]>
By: Anubhav Jainhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-54688 Mon, 22 Aug 2011 10:46:43 +0000 https://undocumentedmatlab.com/?p=1917#comment-54688 Hi,
I want to enquire about the events generated upon opening or closing a dialog box(e.g-Function Block Parameters or Source Block Parameters). Is there any way I can get these events and register their listeners.
Thanks & Regards
Anubhav Jain

]]>
By: Karthik Ponuduraihttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-39219 Fri, 08 Apr 2011 08:03:57 +0000 https://undocumentedmatlab.com/?p=1917#comment-39219 Hi Suganya,

I personally have not worked with Servlets or web application. I don’t think MATLAB includes the java libraries for servlets in the static library path, but you could add the libraries to the dynamic path during runtime and then access all the classes within MATLAB.

Sorry for the late reply as I did not receive a notification email. If you have any further question, email me at karthik.ponudurai@gmail.com

Karthik

]]>
By: Suganyahttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-33231 Sat, 12 Feb 2011 07:16:12 +0000 https://undocumentedmatlab.com/?p=1917#comment-33231 Hi Karthik

I am working in a project similar to what you have said above . We are using NetBeans to create our own web application and we need to interface Matlab with JSP and servlets. Since servlets is the Java code, will we be able to interface it with Matlab in the way you have said above?

Regards
Suganya

]]>
By: Karthik Ponuduraihttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-21225 Thu, 28 Oct 2010 09:52:58 +0000 https://undocumentedmatlab.com/?p=1917#comment-21225 Hi Mikhail, got you now. Let me know how it goes. Good luck!

]]>
By: Mikhailhttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-21175 Wed, 27 Oct 2010 21:21:38 +0000 https://undocumentedmatlab.com/?p=1917#comment-21175 @Karthik: you misunderstood me. See my first link – the solution I tried three years ago very is similar to yours! Bur I encountered problems with it and had to stay with JMI which works fine. I will try your solution on this weekend!

]]>
By: Karthik Ponuduraihttps://undocumentedmatlab.com/blog_old/matlab-java-interface-using-static-control#comment-20874 Sun, 24 Oct 2010 09:42:06 +0000 https://undocumentedmatlab.com/?p=1917#comment-20874 Hi Eric,

To build a pratical Java GUI in MATLAB you still need to keep the main Window as MATLAB figure and use Yair’s UISpiltPane (http://www.mathworks.com/matlabcentral/fileexchange/23073) to divide MATLAB figure into sub panels. The reason for using MATLAB figure is because currently you still need a MATLAB’s uipanel to add a plotting axes (http://www.mathworks.de/matlabcentral/newsreader/view_thread/148719).

You can then use JControl (http://www.mathworks.com/matlabcentral/fileexchange/15580-using-java-swing-components-in-matlab) to integrate Java components (example java JPanel, JDesktopPane, etc…) to the sub panels.

It’s also worth looking at Infonode (http://www.infonode.net/) Java GUI inplementation which allows docking windows. I have implemented Infonode in MATLAB and it does extend the MATLAB’s GUI capability.

Karthik

]]>