From: Ramiro Massol on
i'm trying to use some java uicontrols (jslider, jprogressbar) but i don't know how to set their properties.
For example, I would like to change the font type and size of a jslider and so far i've got to this:
figure
h = uicomponent('style','slider', 'position',[150,50,180,50], 'value',70, ...
'MajorTickSpacing',20, 'MinorTickSpacing',5, ...
'Paintlabels',1,'PaintTicks',1, 'Orientation',0);
jSlider = findjobj(h,'nomenu');
jSlider.setFont('Comic Sans MS', 'PLAIN', 28)


but the jslider font remains unchanged.

please help!

best
From: Yair Altman on
"Ramiro Massol" <ramiro.massol(a)childrens.harvard.edu> wrote in message <hitapk$o58$1(a)fred.mathworks.com>...
> i'm trying to use some java uicontrols (jslider, jprogressbar) but i don't know how to set their properties.
> For example, I would like to change the font type and size of a jslider and so far i've got to this:
> figure
> h = uicomponent('style','slider', 'position',[150,50,180,50], 'value',70, ...
> 'MajorTickSpacing',20, 'MinorTickSpacing',5, ...
> 'Paintlabels',1,'PaintTicks',1, 'Orientation',0);
> jSlider = findjobj(h,'nomenu');
> jSlider.setFont('Comic Sans MS', 'PLAIN', 28)
>
>
> but the jslider font remains unchanged.
>
> please help!
>
> best

Hi again Ramiro :-)

You were nearly correct in your syntax - the correct version is:
jSlider.setFont(java.awt.Font('Comic Sans MS',java.awt.Font.PLAIN,28))

Also, there is no need to use findjobj() to get the Java handle - it is already returned by uicomponent() as a field of the returned handle:

h = uicomponent('style','slider',...);
jSlider = h.JavaComponent;

Yair Altman
http://UndocumentedMatlab.com
From: Ramiro Massol on
thanks Yair for your help! You mentioned that uicomponent provides also the java handle for the component, how is this? the handle obtained after :
h = uicomponent(......

is a matlab handle.

another question. how do you control the appearance of the track/cursor of jslider? how to set the step of the jslider to go one unit per click and not to jump so much?

by the way, i'll write to you soon about our jtable project for an upgrade.

best

"Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <hitgl3$2ga$1(a)fred.mathworks.com>...
> "Ramiro Massol" <ramiro.massol(a)childrens.harvard.edu> wrote in message <hitapk$o58$1(a)fred.mathworks.com>...
> > i'm trying to use some java uicontrols (jslider, jprogressbar) but i don't know how to set their properties.
> > For example, I would like to change the font type and size of a jslider and so far i've got to this:
> > figure
> > h = uicomponent('style','slider', 'position',[150,50,180,50], 'value',70, ...
> > 'MajorTickSpacing',20, 'MinorTickSpacing',5, ...
> > 'Paintlabels',1,'PaintTicks',1, 'Orientation',0);
> > jSlider = findjobj(h,'nomenu');
> > jSlider.setFont('Comic Sans MS', 'PLAIN', 28)
> >
> >
> > but the jslider font remains unchanged.
> >
> > please help!
> >
> > best
>
> Hi again Ramiro :-)
>
> You were nearly correct in your syntax - the correct version is:
> jSlider.setFont(java.awt.Font('Comic Sans MS',java.awt.Font.PLAIN,28))
>
> Also, there is no need to use findjobj() to get the Java handle - it is already returned by uicomponent() as a field of the returned handle:
>
> h = uicomponent('style','slider',...);
> jSlider = h.JavaComponent;
>
> Yair Altman
> http://UndocumentedMatlab.com
From: Yair Altman on
"Ramiro Massol" <ramiro.massol(a)childrens.harvard.edu> wrote in message...
> thanks Yair for your help! You mentioned that uicomponent provides also the java handle for the component, how is this? the handle obtained after :
> h = uicomponent(......
> is a matlab handle.

uicomponent attaches the JavaComponent property to the h handle using the undocumented schema.prop function. Take a look within the uicomponent.m source code, which is pretty-well documented.

> another question. how do you control the appearance of the track/cursor of jslider? how to set the step of the jslider to go one unit per click and not to jump so much?

JSlider has a variety of properties that you can set to customize its appearance and behavior. Type set(jslider) or get(jslider) or inspect(jslider) to see the list of properties. You can also use a variety of built-in methods and callbacks - use my UIInspect utility from the File Exchange to see them. Here's the official documentation:

http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html
http://java.sun.com/javase/6/docs/api/javax/swing/JSlider.html

Yair Altman
http://UndocumentedMatlab.com
From: Ramiro Massol on
thanks for the tips. I now can set some properties but i'm still at odds about the default behavior of jslider. For instance, it only calls my callback after the mouse is released and not during dragging. I checked everywhere and you mentioned in a previous post that there is a method called 'AdjustmentValueChangedCallback ' to allow the detection of the movement of the slider. I cannot see this method in my jslider callback or methods. How can i set a callback associated to dragging the cursor of the slider?

best
"Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <hivd9o$bo9$1(a)fred.mathworks.com>...
> "Ramiro Massol" <ramiro.massol(a)childrens.harvard.edu> wrote in message...
> > thanks Yair for your help! You mentioned that uicomponent provides also the java handle for the component, how is this? the handle obtained after :
> > h = uicomponent(......
> > is a matlab handle.
>
> uicomponent attaches the JavaComponent property to the h handle using the undocumented schema.prop function. Take a look within the uicomponent.m source code, which is pretty-well documented.
>
> > another question. how do you control the appearance of the track/cursor of jslider? how to set the step of the jslider to go one unit per click and not to jump so much?
>
> JSlider has a variety of properties that you can set to customize its appearance and behavior. Type set(jslider) or get(jslider) or inspect(jslider) to see the list of properties. You can also use a variety of built-in methods and callbacks - use my UIInspect utility from the File Exchange to see them. Here's the official documentation:
>
> http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html
> http://java.sun.com/javase/6/docs/api/javax/swing/JSlider.html
>
> Yair Altman
> http://UndocumentedMatlab.com