Differences between slider and scale in SWT

Source: Internet
Author: User

In the past, we thought that slider and scale are only the differences in appearance. Today we found that this is not the case, because slider has a feature: getselection () can get the most
The iterator is not the value of getmaximum (). It must be subtracted from the getthumb () value. The latter is the value of the middle slider. The default value is 10 and the minimum value is 1. Run thisProgramObserve
Output.

Import Org. Eclipse. SWT. * ;
Import Org. Eclipse. SWT. Events. selectionadapter;
Import Org. Eclipse. SWT. Events. selectionevent;
Import Org. Eclipse. SWT. widgets. * ;

Public ClassSlidertest {

Public   Static   Void Main (string [] ARGs ){
Display display =   New Display ();
Shell =   New Shell (Display );

// Slider
Final Slider =   New Slider (shell, SWT. Horizontal );
Slider. setbounds ( 10 , 10 , 200 , 32 );
Slider. setminimum ( 0 );
Slider. setmaximum ( 100 );
Slider. setthumb ( 5 );
Slider. addselectionlistener ( New Selectionadapter (){
Public   Void Widgetselected (selectionevent e ){
System. Out. println ( " Slider selection: "   + Slider. getselection ());
}
});

// Scale
Final Scale =   New Scale (shell, SWT. Horizontal );
Scale. setbounds ( 10 , 50 , 200 , 72 );
Scale. setminimum ( 0 );
Scale. setmaximum ( 100 );
Scale. addselectionlistener ( New Selectionadapter (){
Public   Void Widgetselected (selectionevent e ){
System. Out. println ( " Scale selection: "   + Scale. getselection ());
}
});

shell. open ();
while ( ! shell. isdisposed () {
If ( ! display. readanddispatch ()
display. sleep ();
}< br> display. dispose ();
}< BR >}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.