When you use Java Swing or Java Foundation Classes (JFC) for your GUI application development the look and feel of GUI application is not the same as the look and feel of your operating system as JFC or Java Swing has its own built in look and feel. Although, if you want you can achieve the same look and feel as of your operating system's by using Java's Abstract Window Toolkit (AWT), the AWT toolkit is unable to meet advanced GUI programming requirement.
The Java Foundation Classes
AWT (the Abstract Windowing Toolkit) was the first Java GUI toolkit, introduced with JDK 1.0 as one component of the Sun Microsystems Java standard. The relatively primitive AWT wrapped Java code around native (operating system-supplied) objects to create GUI elements, such as menus, windows and buttons. AWT was a very thin wrapper around native widgets, exposing developers to platform specific code, quirks and bugs that limited how portable and native-looking applications could be across different
Text is a selectable user interface objects that allow the user to enter and modify text. Events associated with Text are: DefaultSelection, Modify, Verify. Different Text styles are CENTER, LEFT, MULTI, PASSWORD, SINGLE, RIGHT, READ_ONLY, WRAP. Please note that only one of the styles MULTI and SINGLE may be specified.
The following are the important constructors of Text class.
Text(Composite parent, int style)
Constructs a new instance of this class given its
Menu are user interface objects that contain menu items. The Menu support styles BAR, DROP_DOWN, POP_UP, NO_RADIO_GROUP, LEFT_TO_RIGHT, RIGHT_TO_LEFT. Please note that only one of BAR, DROP_DOWN and POP_UP may be specified. Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
The following are the important constructors of Menu class.
Constructs a new instance of this class given its parent, and sets the style for the instance so
List is a selectable user interface object that displays a list of strings and issues notification when a string selected. A list may be single or multi select. Events associated with List are Selection, DefaultSelection. Please note that only one of SINGLE and MULTI style may be specified.
The following are the important constructors of List class.
List(Composite parent, int style)
Constructs a new instance of this class given its parent and a style value describing
A label displays a string or an image. The string can be changed by the application, but a user cannot edit it directly. For Label, when SEPARATOR is specified, displays a single vertical or horizontal line.
The following are the important constructors of Label class.
Label(Composite parent, int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
The following are the important
A group is also a control that can contain other controls. A group is surrounded by a border and may, optionally, contain a title. As with composites, the position of each control inside a group is relative to the group, so if the group is moved on the shell, the controls inside the group retain their relative positions.
Group provide an etched border with an optional title. Shadow styles are hints and may not be honored by the platform. To create a group with the default shadow style
Dialog class is the abstract superclass of the classes that represent the built in platform dialogs. A Dialog typically contains other widgets that are not accessible. A Dialog is not a Widget.
This class can also be used as the abstract superclass for user-designed dialogs. Such dialogs usually consist of a Shell with child widgets. The basic template for a user-defined dialog typically looks something like this: Java Code: import org.eclipse.swt.*;
Composite are controls which are capable of containing other controls. Controls are placed inside a composite in the same manner that Controls are placed on a shell. The position of each widget inside a composite is relative to the composite, so if the composite is moved on the shell, the Controls inside the composite retain their relative positions.
The styles supported by composites are NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP, EMBEDDED, DOUBLE_BUFFERED.
Combo are controls that allow the user to choose an item from a list of items, or optionally enter a new value by typing it into an editable text field. Often, Combos are used in the same place where a single selection List widget could be used but space is limited. A Combo takes less space than a List widget and shows similar information.
The following are the important constructors of Combo class.
Combo(Composite parent, int style)
Constructs a new instance
Canvas provide a surface for drawing arbitrary graphics. It supports no styles and events. This is a subclass of class Composite.
This class may be subclassed by custom control implementors who are building controls that are not constructed from aggregates of other controls. That is, they are either painted using SWT graphics calls or are handled by native methods.
The following are the important constructors of Canvas class.
In order to work with events in SWT, you create a listener specific to the event that you wish to capture. There is an interface for each listener that you can use (for example SelectionListener). There is also a class that will provide you with the event information (for example SelectionEvent). Within the listener that you create, you must implement the methods defined in the interface. Java Code: SelectionListener listener = new SelectionListener()
SelectionListener listener = new SelectionListener()