diff --git a/src/main/java/fiji/plugin/trackmate/gui/components/ConfigureViewsPanel.java b/src/main/java/fiji/plugin/trackmate/gui/components/ConfigureViewsPanel.java index 57a48197d..fc7302fa1 100644 --- a/src/main/java/fiji/plugin/trackmate/gui/components/ConfigureViewsPanel.java +++ b/src/main/java/fiji/plugin/trackmate/gui/components/ConfigureViewsPanel.java @@ -335,7 +335,10 @@ public ConfigureViewsPanel( chckbxLimitZDepth.setFont( SMALL_FONT ); panelDrawingZDepth.add( chckbxLimitZDepth ); - final SpinnerNumberModel numberModelDrawingZDepth = new SpinnerNumberModel( ds.getZDrawingDepth(), 0.5, 5000., 0.5 ); + final double minZDrawingDepth = 0.5; + final double maxZDrawingDepth = 5000.; + final double zDrawingDepth = Math.min( Math.max( ds.getZDrawingDepth(), minZDrawingDepth ), maxZDrawingDepth ); + final SpinnerNumberModel numberModelDrawingZDepth = new SpinnerNumberModel( zDrawingDepth, minZDrawingDepth, maxZDrawingDepth, 0.5 ); final JSpinner spinnerDrawingZDepth = new JSpinner( numberModelDrawingZDepth ); spinnerDrawingZDepth.setFont( SMALL_FONT ); panelDrawingZDepth.add( spinnerDrawingZDepth ); diff --git a/src/main/java/fiji/plugin/trackmate/gui/displaysettings/SliderPanel.java b/src/main/java/fiji/plugin/trackmate/gui/displaysettings/SliderPanel.java index 1b00641c2..3af77b6e7 100644 --- a/src/main/java/fiji/plugin/trackmate/gui/displaysettings/SliderPanel.java +++ b/src/main/java/fiji/plugin/trackmate/gui/displaysettings/SliderPanel.java @@ -70,7 +70,11 @@ public SliderPanel( final String name, final BoundedValue model, final int spinn slider = new JSlider( SwingConstants.HORIZONTAL, model.getRangeMin(), model.getRangeMax(), model.getCurrentValue() ); spinner = new JSpinner(); - spinner.setModel( new SpinnerNumberModel( model.getCurrentValue(), model.getRangeMin(), model.getRangeMax(), spinnerStepSize ) ); + + final double min = model.getRangeMin(); + final double max = model.getRangeMax(); + final double val = Math.max( Math.min( model.getCurrentValue(), max ), min ); + spinner.setModel( new SpinnerNumberModel( val, min, max, spinnerStepSize ) ); slider.addChangeListener( new ChangeListener() { diff --git a/src/main/java/fiji/plugin/trackmate/gui/displaysettings/SliderPanelDouble.java b/src/main/java/fiji/plugin/trackmate/gui/displaysettings/SliderPanelDouble.java index 9e49e5162..e91d751c5 100644 --- a/src/main/java/fiji/plugin/trackmate/gui/displaysettings/SliderPanelDouble.java +++ b/src/main/java/fiji/plugin/trackmate/gui/displaysettings/SliderPanelDouble.java @@ -88,10 +88,11 @@ public SliderPanelDouble( dmin = model.getRangeMin(); dmax = model.getRangeMax(); + final double val = Math.min( Math.max( model.getCurrentValue(), dmin ), dmax ); - slider = new JSlider( SwingConstants.HORIZONTAL, 0, sliderLength, toSlider( model.getCurrentValue() ) ); + slider = new JSlider( SwingConstants.HORIZONTAL, 0, sliderLength, toSlider( val ) ); spinner = new JSpinner(); - spinner.setModel( new SpinnerNumberModel( model.getCurrentValue(), dmin, dmax, spinnerStepSize ) ); + spinner.setModel( new SpinnerNumberModel( val, dmin, dmax, spinnerStepSize ) ); slider.addChangeListener( new ChangeListener() {