Comments for Undocumented Matlab https://undocumentedmatlab.com Charting Matlab's unsupported hidden underbelly Fri, 15 Feb 2019 10:51:29 +0000 hourly 1 https://wordpress.org/?v=4.4.1 Comment on Setting status-bar components by Yair Altmanhttps://undocumentedmatlab.com/blog/setting-status-bar-components#comment-462147 Fri, 15 Feb 2019 10:51:29 +0000 http://undocumentedmatlab.com/?p=478#comment-462147 Matlab’s statusbar hack only works with non-docked figures. If you need them to work also in docked figures, replicate the functionality using regular panels.

]]>
Comment on Setting status-bar components by Yair Altmanhttps://undocumentedmatlab.com/blog/setting-status-bar-components#comment-462146 Fri, 15 Feb 2019 10:48:59 +0000 http://undocumentedmatlab.com/?p=478#comment-462146 Jan – if you mean the controls in the statusbar, the only controls that change their relative position are the ones that are attached to right (“East”) border, such as the “Next phase” button in my example in the post. If you wish them to remain in the same relative position, attach them to the left (“West”) instead.

]]>
Comment on Sliders in Matlab GUI by Yair Altmanhttps://undocumentedmatlab.com/blog/sliders-in-matlab-gui#comment-462141 Fri, 15 Feb 2019 10:24:12 +0000 http://undocumentedmatlab.com/?p=5827#comment-462141 The slider thumb color is typically set by the Look&Feel and cannot be changed, except by changing the L&F’s standard control color (which is not advisable).
To update the Look-&-Feel in Matlab GUI, look here: https://undocumentedmatlab.com/blog/modifying-matlab-look-and-feel.

A few L&Fs may honor the settable internal Slider.thumb client property, but I’m not sure which L&Fs and under which circumstances (for example, it might depend on your Operating System and/or the Matlab release [which affects the version of Java]):

jSlider = javaObjectEDT(javax.swing.JSlider(0,100,20));
jColor = java.awt.Color(1.0,0.0,0.0);  % red
jSlider.putClientProperty('Slider.thumb',jColor);
[hjSlider,hContainer] = javacomponent(jSlider, [10,10,100,20], gcf);

but as I said above, many L&Fs ignore this property. Discovering how to proceed from here is a pure Java issue, unrelated to Matlab, so I leave this up to you and other readers to figure out on Java forums. Here are 2 places to get you started: link1, link2.

]]>
Comment on Matlab toolstrip – part 6 (complex controls) by Yair Altmanhttps://undocumentedmatlab.com/blog/matlab-toolstrip-part-6-complex-controls#comment-462041 Thu, 14 Feb 2019 22:54:36 +0000 https://undocumentedmatlab.com/?p=8235#comment-462041 @Batuhan – I don’t know what exactly happened in your specific case, but it could be that you are not storing the ToolGroup handle in a persistent location, as I explained in an earlier post at the beginning of this miniseries:

“An annoying quirk with ToolGroups is that they automatically close when their reference handle is deleted from Matlab memory. The specific behavior changes depending on the contents of the container and the Matlab release, but in general it’s safest to preserve the hToolGroup variable, to prevent the window from closing, when this variable goes out of scope, when the function (in which we create the ToolGroup) returns. …”

]]>
Comment on Matlab callbacks for Java events by RichardSThttps://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events#comment-460786 Fri, 08 Feb 2019 15:21:35 +0000 http://undocumentedmatlab.com/?p=1987#comment-460786 Hello All,
Ok, I see that I was doing wrong. I needed to:
i) wrap the event in a handle, as per the advice above
ii) change the callback to display the event’s properties

>> evt = EventTest
evt =
EventTest@5d332969
>> h = handle(evt,'Callbackproperties')
h =
	javahandle_withcallbacks.EventTest
>> set(evt,'TestEventCallback',@(h,e)disp([e.newValue e.oldValue]))
>> evt.notifyMyTest
     1     0
>> get(evt)
                    Class: [1×1 java.lang.Class]
        TestEventCallback: @(h,e)disp([e.newValue,e.oldValue])
    TestEventCallbackData: []

Thank you for your help, Yair.
Richard

]]>
Comment on Real-time trading system demo by Yair Altmanhttps://undocumentedmatlab.com/ib-matlab/real-time-trading-system-demo#comment-460777 Fri, 08 Feb 2019 14:22:20 +0000 http://undocumentedmatlab.com/?page_id=3963#comment-460777 For all those who are interested, I have updated the files and they are now compatible with all Matlab releases up to the latest (currently R2019a):
https://undocumentedmatlab.com/files/Matlab-trading-demo.zip

]]>
Comment on Matlab callbacks for Java events by RichardSThttps://undocumentedmatlab.com/blog/matlab-callbacks-for-java-events#comment-460774 Fri, 08 Feb 2019 14:01:54 +0000 http://undocumentedmatlab.com/?p=1987#comment-460774 Hello Yair,
Is this still meant to work in later versions of MATLAB?

With my version of
MATLAB Version 9.4 (R2018a)
My results are:

>> evt = EventTest
evt =
EventTest@71652c98
>> get(evt)
    Class: [1×1 java.lang.Class]
>> set(evt,'TestEventCallback',@(h,e)disp(h))
>> evt.notifyMyTest
	javahandle_withcallbacks.EventTest

Have I done something silly?
Thank you for your help.
Richard S-T (who owns both ‘Undocumented’ and ‘Accelerating’)

]]>
Comment on Uitable customization report by Michelehttps://undocumentedmatlab.com/blog/uitable-customization-report#comment-460481 Wed, 06 Feb 2019 16:57:35 +0000 http://undocumentedmatlab.com/?p=2396#comment-460481 Dear Yair,

I would like to be able to enable/disable editing of specific cells in my table (not just the whole column!), and perhaps also grey-out the disabled cells.
Does your report cover this topic? And if not, do you have any suggestions on how to achieve this? (Possibly understandable also by a non-Java programmer!)

And as usual, thanks for the outstanding work!

]]>
Comment on Sliders in Matlab GUI by jmarcohttps://undocumentedmatlab.com/blog/sliders-in-matlab-gui#comment-460341 Tue, 05 Feb 2019 21:38:21 +0000 http://undocumentedmatlab.com/?p=5827#comment-460341 @Yair Altman – Thanks for the quick response. I’ll investigate the color properties some more. I tried changing the look and feel using the directions on your website, but each one (Metal, Nimbus, Motif, and GTK) has an unfilled slider.
I found an option that looks promising: modifying the client properties to set “isFilled” to true.

Interestingly, in the application I’m working on, I don’t get a filled JSlider, but as I was putting together an example to show how it didn’t work, I got a filled JSlider!

So, here’s the working example:

f = figure;
jSlider = javaObjectEDT(javax.swing.JSlider(0,100,20));
jSlider.putClientProperty('JSlider.isFilled', java.lang.Boolean.TRUE)
[jsl,hsl] = javacomponent(jSlider);

Now I just have to figure out how to make it work with my application.

]]>
Comment on Sliders in Matlab GUI by Yair Altmanhttps://undocumentedmatlab.com/blog/sliders-in-matlab-gui#comment-460336 Tue, 05 Feb 2019 21:15:14 +0000 http://undocumentedmatlab.com/?p=5827#comment-460336 This is not a settable property of the standard Swing JSlider. You need to modify the slider’s look-&-feel properties. These include several color properties, so play around a bit.
To update the Look-&-Feel in Matlab GUI, look here: https://undocumentedmatlab.com/blog/modifying-matlab-look-and-feel.

]]>
Comment on Sliders in Matlab GUI by jmarcohttps://undocumentedmatlab.com/blog/sliders-in-matlab-gui#comment-460332 Tue, 05 Feb 2019 20:49:21 +0000 http://undocumentedmatlab.com/?p=5827#comment-460332 Is there a way to color in the slider between the lower bound and the current value? Here’s an example of what I mean: (in case the image doesn’t load, this image is from the Oracle documentation on sliders).

In MATLAB, the slider track doesn’t have either side colored in. I’ve tried switching the look & feel to every built in option, but none of them gives me something like I see on Oracle’s website. There doesn’t seem to be a property on the slider itself that can be changed to do this.

]]>
Comment on Using pure Java GUI in deployed Matlab apps by Yair Altmanhttps://undocumentedmatlab.com/blog/using-pure-java-gui-in-deployed-matlab-apps#comment-460294 Tue, 05 Feb 2019 14:41:12 +0000 http://undocumentedmatlab.com/?p=4909#comment-460294 Alternatively, set the Java frame’s default close operation to DISPOSE_ON_CLOSE, as follows:

jFrame.setDefaultCloseOperation(jFrame.DISPOSE_ON_CLOSE);  % rather than EXIT_ON_CLOSE
]]>
Comment on Using pure Java GUI in deployed Matlab apps by Yair Altmanhttps://undocumentedmatlab.com/blog/using-pure-java-gui-in-deployed-matlab-apps#comment-460252 Tue, 05 Feb 2019 09:44:44 +0000 http://undocumentedmatlab.com/?p=4909#comment-460252 @Michael – look here: https://undocumentedmatlab.com/blog/modifying-matlab-look-and-feel
You’d probably want to modify the L&F only during your figure creation, and restore it back to the default immediately following the GUI creation.

]]>
Comment on Using pure Java GUI in deployed Matlab apps by Michaelhttps://undocumentedmatlab.com/blog/using-pure-java-gui-in-deployed-matlab-apps#comment-460250 Tue, 05 Feb 2019 09:31:47 +0000 http://undocumentedmatlab.com/?p=4909#comment-460250 Hi Yair,
thanks very much for this great site and books! This is probably the wrong place to ask a question, so sorry beforehand. I am using Matlab 2015b on Windows 7. I have a function that generates a figure with Java tables, with the standard Windows laf. I tried to change the highlight colour for the text in my figure in the following way:

defaults = javax.swing.UIManager.getLookAndFeelDefaults();
defaults.put('textHighlight', java.awt.Color(1, 0, 0));

As the result the text highlighting of the Matlab Command window changes to red colour, but nothing changes in any of the figures. Pausing and drawnow doesn’t help. Is there a workaround?

]]>
Comment on Matlab toolstrip – part 8 (galleries) by Gephttps://undocumentedmatlab.com/blog/matlab-toolstrip-part-8-galleries#comment-460103 Mon, 04 Feb 2019 11:47:11 +0000 https://undocumentedmatlab.com/?p=8321#comment-460103 Can’t thank you enough for your quick response.
Hope the api doesn’t change much so we can play as long as possible :)

]]>
Comment on Matlab toolstrip – part 8 (galleries) by Yair Altmanhttps://undocumentedmatlab.com/blog/matlab-toolstrip-part-8-galleries#comment-460101 Mon, 04 Feb 2019 11:29:22 +0000 https://undocumentedmatlab.com/?p=8321#comment-460101 I think the only major performance hit is in the initial rendering. I did not notice any sluggishness when updating the internal figures, but I never ran a thorough benchmark.

]]>
Comment on Matlab toolstrip – part 8 (galleries) by Gephttps://undocumentedmatlab.com/blog/matlab-toolstrip-part-8-galleries#comment-460100 Mon, 04 Feb 2019 11:25:30 +0000 https://undocumentedmatlab.com/?p=8321#comment-460100 Thank you for your answer.
Except the initial performance hit you mentioned when rendering the figure with toolstrip for the first time, is there also a UI response degradation while using/updating the figure axes/contents assuming option 1 (pure legacy figures) ?

]]>
Comment on Matlab toolstrip – part 8 (galleries) by Yair Altmanhttps://undocumentedmatlab.com/blog/matlab-toolstrip-part-8-galleries#comment-460093 Mon, 04 Feb 2019 10:40:22 +0000 https://undocumentedmatlab.com/?p=8321#comment-460093 @Gep – yes, apps and toolstrip take a few seconds to render before being ready. This is noticeably slower than corresponding legacy (Java-based figure) GUIs. Hopefully the performance will improve in future Matlab releases.

That being said, apps and toolstrips provide a radically different way for UI interactivity than the legacy GUI, and the performance impact might well be offset by the sleek-looking appearance. This tradeoff is not much different from that of AppDesigner-vs.-GUIDE — AppDesigner-created uifigures display much more polished UIs than GUIDE, yet are significantly slower to render.

The big benefit here is that you have a choice. You can decide for yourself, based on your specific needs and aesthetic preferences, whether to base your GUI on (1) pure legacy figures, or (2) a combination of apps/toolstrips/figures, or (3) pure AppDesigner/uifigures. I am a strong advocate of not hiding the full set of available tools from users, and letting users decide for themselves what’s best for them.

]]>
Comment on Matlab toolstrip – part 8 (galleries) by gephttps://undocumentedmatlab.com/blog/matlab-toolstrip-part-8-galleries#comment-460092 Mon, 04 Feb 2019 10:33:57 +0000 https://undocumentedmatlab.com/?p=8321#comment-460092 Hello and thank you for all the toolstrip tips :)

I have one question w.r.t. to performance: assuming a gui app, not based on GUIDE, which is fairly optimized (I am following your advice/books for years), is there a significant overhead converting/using a toolstrip?

]]>
Comment on Using pure Java GUI in deployed Matlab apps by Lukaszhttps://undocumentedmatlab.com/blog/using-pure-java-gui-in-deployed-matlab-apps#comment-459572 Fri, 01 Feb 2019 16:32:32 +0000 http://undocumentedmatlab.com/?p=4909#comment-459572 To avoid the closing problem (closing the window also closes JVM/Matlab), it is enough to implement the WindowListener interface and overwrite the windowClosing method, so there is no EXIT_ON_CLOSE (i.e. System.exit(0)).

E.g.

public class JavaWindow
        extends JFrame implements WindowListener{
...
@Override
    public void windowClosing(WindowEvent e) {
 
    }
]]>