0% found this document useful (0 votes)
97 views12 pages

Swt1-Introduction To SWT

This document discusses the differences between SWT, AWT, and Swing. It provides 3 key points: 1. SWT uses native operating system widgets, while AWT and Swing are implemented in pure Java code. This makes SWT look and behave consistently with the local system but be incompatible across systems. 2. The development process for SWT applications involves using the Eclipse IDE, downloading SWT packages, and optionally using WindowBuilder. 3. SWT follows the MVC design pattern, with components as the model storing data, widgets as the views displaying it, and listeners as controllers handling user interactions.

Uploaded by

Desire Goore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views12 pages

Swt1-Introduction To SWT

This document discusses the differences between SWT, AWT, and Swing. It provides 3 key points: 1. SWT uses native operating system widgets, while AWT and Swing are implemented in pure Java code. This makes SWT look and behave consistently with the local system but be incompatible across systems. 2. The development process for SWT applications involves using the Eclipse IDE, downloading SWT packages, and optionally using WindowBuilder. 3. SWT follows the MVC design pattern, with components as the model storing data, widgets as the views displaying it, and listeners as controllers handling user interactions.

Uploaded by

Desire Goore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

CHPT1.

INTRODUCTION
TO SWT
1. SWING VS SWT
In earlier version of JDK, the functions of graphical user interface have been
greatly expanded to form a complete set of API collections, called Java
foundation class (JFC).

The earliest GUI tool set provided by Java is AWT (Abstract window toolkit).
This package provides a set of interfaces to interact with the local graphical
interface.
It is the basic tool provided by java to establish and set up the graphical user
interface of Java.
ABOUT AWT…
There is a one-to-one correspondence between the graphics function in AWT
and the graphics function provided by the operating system, which is called
peers.

When using AWT to write the graphical user interface, it is actually using the
graphics library provided by the local operation system.
different operating systems have different interfaces (different style), even
different functions
SWING
Swing component is an extension of AWT component, which provides many
new graphical user interface components.
Swing components are implemented in pure Java, and their performance is
consistent on different platforms.
Swing component has no local code, does not depend on the support of
specific local operating system, and has the ability to provide other features
not supported by local system, which is the biggest difference between Swing
component and AWT component.
Disadvantages: the appearance or style provided by Swing is incompatible with the
local system.
SWT
SWT is an open source widget toolkit for Java designed to provide efficient,
portable access to the user-interface facilities of the operating systems on
which it is implemented.
Download website: https://www.eclipse.org/swt/
WHAT’S DIFFERENT
SWT uses the widgets provided by the operating system to render its graphical
application. The object in the control class has a direct counterpart in the
operating system, which can be used through the handle of the class.
In addition to the control class, SWT also provides many components. The
specific hierarchy is shown in Figure 1-1
Widget

Caret ScrollBar Item Control Menu DropTarget Tracker

Label Sash ProgressBar Button Scrollable Scale Slider

List Composite Text


2. PREPARATION BEFORE
DEVELOPMENT
1) Eclipse: Eclipse IDE for Java Developers (or MyEclipse)
http://www.eclipse.org/downloads/ Core packages in SWT

1 ) org.eclipse.swt.widgets ;

2 ) org.eclipse.swt.layout ;
2) SWT package: swt-3.5.2-win32-win32-x86.zip 
3 ) org.eclipse.swt.custom ;
http://www.eclipse.org/swt/ 
4 ) org.eclipse.swt.event ;

5 ) org.eclipse.swt.graphics ;

3) WindowBuilder:

6 ) org.eclipse.swt.ole.win32

http://www.eclipse.org/windowbuilder/download.php

URL: https://download.eclipse.org/windowbuilder/1.9.7/
SWT PROGRAM
DEVELOPMENT STEPS
Let's take a look at how to develop an SWT application using Eclipse, which con-
sists of the following four steps:
1) New Java project: HelloLabel;
2) Set the construction path of the project
Right-click on the project name, Build Path Configure Build Path, click Add Ex-
ternal JARs;
Positioning to the eclipse \ plugins in the org. Eclipse. SWT. Win32. Win32. X86_3.
100.1 v4236b. Jar and org. Eclipse swt_3. 100.1 v4236b. Jar;
3) Create a new class HelloLabel.
Here's the code
3. MVC PATTERN VERSUS SWT
The model, view, and control classes in MVC are shown below:
3. MVC PATTERN VERSUS SWT
Model-view-controller (MVC: Model-View-Controller) is a
structural organization Model of interactive interfaces.
MVC, proposed by Trygve Reenskaug, was first applied in the
Smalltalk-80 environment, making many interaction and interface
systems form the basis. Microsoft's MFC basic classes also follow
the IDEA of MVC.
For the need of interface design variability, MVC decomposes the
composition of interactive system into model, view and control
components.
3. MVC PATTERN VERSUS SWT
Now combine Java SWT to illustrate the MVC design pattern:
Model: Is the place where SWT component data is stored. For example, the
Table Model stores all data on the Table. Responsible for data
maintenance. Models typically provide methods for accessing and modifying
data. The model also sends events to the registered views as the model
changes, and the views update themselves based on the model changes.
View: refers to the appearance of SWT components. Responsible for provid-
ing viewable views of part of the model's data.
Controller: Handles events for the view in response to user actions on the
SWT component. Swing listeners such as mouse and action listeners are
MVC controllers.

You might also like