Two knob slider for a GUI or app
61 次查看(过去 30 天)
显示 更早的评论
Hello,
For sorting out timing events I need a slider with two knobs, see picture taken from internet. Anyone a suggestion or a trick how implement this (UIspace) efficient in a matlab UI or App. Now it is implemented with two sliders: one for the min value and one for the max value. This is not so space efficient when you need of 10 these slider pairs.
Thanks,
Patrick
1 个评论
Adam
2018-1-26
If you want to go a little 'off-piste', you can use a Java range slider as detailed in Yair Altman's blog post:
I have used these a few times. I created a class to handle it, but you can just put the raw code in for single usage easily enough.
采纳的回答
更多回答(3 个)
Peter Cook
2018-1-26
编辑:Peter Cook
2018-1-26
I have dabbled with this a couple times myself. As Adam mentioned, you could use a range slider, but what if you want multiple thumbs? You've got options.
1. Use multiple thumbs. Here's an example I sandboxed awhile back:
hFig1 = figure('pos',[64,64,768,128]);
hFig1.ToolBar = 'none';
hFig1.MenuBar = 'none';
hFig1.Name = 'Select Frequency Range(s) in Hz';
hFig1.NumberTitle = 'off';
sliderWidth = 32;
for k = 1:20
jSlider{k} = javax.swing.JSlider;
jSlider{k}.setOpaque(false);
javacomponent(jSlider{k},[sliderWidth*(k-1),32,1.5*sliderWidth,45]);
sliderMin = 2*(k-1);
sliderValue = 2*k-1;
sliderMax = 2*k;
set(jSlider{k},'Value',sliderValue,...
'MajorTickSpacing',1,...
'PaintLabels',true,...
'PaintTicks',true,...
'Minimum',sliderMin,...
'Maximum',sliderMax);
hjSlider{k} = handle(jSlider{k},'CallbackProperties');
hjSlider{k}.StateChangedCallback = @(hjSlider,eventData) disp(get(hjSlider,'Value'));
labelTable = java.util.Hashtable();
sliderValueLabel = sprintf('<html>10<sup>%0.1f</sup></html>',sliderValue/10);
jLabel = javax.swing.JLabel(sliderValueLabel);
jLabel.setFont(java.awt.Font('Tahona',0,8));
labelTable.put(int32(sliderValue), jLabel);
jSlider{k}.setLabelTable( labelTable );
end
2. If you're savvy at programming & whatnot, you could extend this object (colormapeditor) to suit your needs:
com.mathworks.page.cmapeditor.CMEditView
3. Do a github search for multislider.java for a pre-built class that does this.
1 个评论
Jasmine Poppick
2023-9-20
Starting in R2023b, you can create a range slider using the uislider function. The component is also available in the App Designer Component Library.
fig = uifigure;
sld = uislider(fig,"range");
0 个评论
Marek Svoboda
2020-2-10
If you are trying to implement this in App Designer (which doesn't support Java), see my answer to a similar question.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!