Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Lables to SWT Scale ticks?

I have a SWT Scale widget, and I need to add labels to the ticks on the scale.

Is there a way to do this? maybe on a Slider widget?

Thanks

like image 340
Tipa Shel Or Avatar asked Nov 05 '22 03:11

Tipa Shel Or


1 Answers

This might be not exactly what you are asking, but you could incorporate a Text widget beside the Scale widget, responding to your Scale values.

For instance:

final Scale scale = new Scale(shell, SWT.HORIZONTAL);   
        scaleValue = new Text(shell, SWT.SINGLE | SWT.BORDER);

        //scale properties omitted...

        scale.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event event) {
                int perspectivevalue = scale.getSelection();
                scaleValue.setText("" + (perspectivevalue));
            }
        });

This has the effect of updating the value in the Text widget given whatever you drag the Scale slider to.

like image 196
braedy. Avatar answered Nov 16 '22 16:11

braedy.