How can I invoke a Java window from an mdl file?
1 view (last 30 days)
Show older comments
I've created a block that looks like this in my mdl file:
Block {
BlockType "S-Function"
Name "FileReader"
...
MaskPromptString "File Name|Output Port Type|Hex|Round|Comment"
MaskStyleString "edit,popup(int|uint|dint|duint|fixed point|"
"dfixed point),checkbox,checkbox,edit"
...
Rather than enter a file name in an editable text field, I want to invoke a Java JFileChooser. Is this possible?
0 Comments
Answers (1)
Kaustubha Govind
on 25 Jul 2012
I would recommend first writing a MATLAB function to call into your Java function and get the selected file name. See Using Java Libraries from MATLAB for documentation regarding this. Once you have tested this, call this from your model's PostLoadFcn or InitFcn callbacks, so that the MATLAB function is called everytime the model is loaded or run. In your MATLAB function, you can also use set_param to set the S-function name to that returned from the Java function. Note that you may need to add the selected folder to the MATLAB path if it isn't already there.
0 Comments
See Also
Categories
Find more on Call Java from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!