SWT: Single-choice button

Source: Internet
Author: User

/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo auto-generated method stub
Display display = display. getdefault ();
Shell shell = new shell (Display );
Shell. setsize (200,200 );
Shell. setlayout (New filllayout (SWT. Horizontal ));
Showradiobutton (Shell );
Shell. open ();

While (! Shell. isdisposed ())
{
If (! Display. readanddispatch ())
{
Display. Sleep ();
}
}

Display. Dispose ();
}

Public static void showradiobutton (shell)
{
// Only one button can be selected among the buttons

// Single-choice button. When creating an object, you must specify the parent class to which the button belongs.
// Set a single-choice button to the selected state by Bt. setselection (true)
// The method used to determine whether a button is selected is Bt. getselection ();

// The first radio button
Group group1 = new group (shell, SWT. shadow_etched_out );
Group1.setlayout (New filllayout (SWT. Vertical ));
Group1.settext ("this is a set of styles ");

Button Bt1 = new button (group1, SWT. Radio | SWT. Left );
Bt1.settext ("SWT. Left ");
Bt1.settooltiptext ("SWT. Left ");

Button bt2 = new button (group1, SWT. Radio | SWT. Right );
Bt2.settext ("SWT. Right ");
Bt2.settooltiptext ("SWT. Right ");

Button bt3 = new button (group1, SWT. Radio | SWT. center );
Bt3.settext ("SWT. Center ");
Bt3.settooltiptext ("SWT. Center ");

// This is the second radio button.
Group group2 = new group (shell, SWT. shadow_etched_out );
Group2.setlayout (New filllayout (SWT. Vertical ));
Group2.settext ("this is another set of styles ");

Button bt4 = new button (group2, SWT. Radio | SWT. Flat );
Bt4.settext ("SWT. Flat ");
Bt4.settooltiptext ("SWT. Flat ");

// Set the initial status
Bt4.setselection (true );

Button BT5 = new button (group2, SWT. Radio | SWT. Border );
Bt5.settext ("SWT. Border ");
Bt5.settooltiptext ("SWT. Border ");

Button bt6 = new button (group2, SWT. Radio );
Bt6.settext ("SWT. Radio ");
Bt6.settooltiptext ("SWT. Radio ");
}

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.