More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Use Group Class in SWT

                         

In this section, you will learn how to use Group class.

In SWT, the class Group of package org.eclipse.swt.widgets provides an etched border with an optional title. In the given example, we have create two groups by using the class Group. In the first group, we have create check boxes and in the second group, radio buttons are defined.

Here is the code of GroupExample.java

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class GroupExample {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    shell.setText("Show Group");
  shell.setSize(200,250);
    Group group1 = new Group(shell, SWT.SHADOW_IN);
    group1.setText("Which are your favourite sports?");
    group1.setLayout(new RowLayout(SWT.VERTICAL));
    new Button(group1, SWT.CHECK).setText("Tennis");
    new Button(group1, SWT.CHECK).setText("FootBall");
    new Button(group1, SWT.CHECK).setText("Cricket");
  new Button(group1, SWT.CHECK).setText("Hockey");
    
  Group group2 = new Group(shell, SWT.SHADOW_IN);
    group2.setText("Where is Taj Mahal?");
    group2.setLayout(new RowLayout(SWT.VERTICAL));
    new Button(group2, SWT.RADIO).setText("Lucknow");
    new Button(group2, SWT.RADIO).setText("Agra");
    new Button(group2, SWT.RADIO).setText("Delhi");
    new Button(group2, SWT.RADIO).setText("Mumbai");

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }

Output will be displayed as:

Download Source Code

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Join and Excel yourself with our Online instructor led training sessions
Training Courses
Tell A Friend
Your Friend Name

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.