Question

I created a slider using uicomponent which can be found on File Exchange

handles.slid=uicomponent('style','slider',0,90,5);
handles.slid.MajorTickSpacing=10;
handles.slid.MinorTickSpacing=10;
handles.slid.Paintlabels=1;
handles.slid.PaintTicks=1;

The labels were initially set as 0 10 20 30 40 50 60 70 80 90

Is it possible to set the labels as a b c d e f g h i j?

Was it helpful?

Solution

You will have to use Java for that. The simplest way I can think of is to modify the existing LabelTable of the JSlider Java component you have already created. Try the following code:

labels = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
lt =get(hu_slider, 'LabelTable');
for i=1:10
    key = java.lang.Integer(10*(i-1));
    val = lt.get(key);
    val.setText(labels{i});
    lt.put(key, val);
end
set(hu_slider, 'LabelTable', lt);
hu_slider.JavaComponent.updateUI;

It works with the assumption that you have 10 ticks, of course.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top