ArticleslgStudy

computer science

Standard Widget Toolkit

Standard Widget Toolkit is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Standard Widget Toolkit rather than just read about it. In short: The Standard Widget Toolkit (SWT) is a graphical widget toolkit for use with the Java platform. It was originally developed by Stephen Northover at IBM and is now maintained by the Eclipse Foundation in tandem with the Eclipse IDE.

Standard Widget Toolkit — main illustration
Standard Widget Toolkit — illustration

Key takeaways

  • Standard Widget Toolkit belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Standard Widget Toolkit to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Standard Widget Toolkit from memory before moving on to harder problems.

Reference excerpt

The Standard Widget Toolkit (SWT) is a graphical widget toolkit for use with the Java platform. It was originally developed by Stephen Northover at IBM and is now maintained by the Eclipse Foundation in tandem with the Eclipse IDE. It is an alternative to the Abstract Window Toolkit (AWT) and Swing Java graphical user interface (GUI) toolkits provided by Sun Microsystems as part of the Java Platform, Standard Edition (J2SE). To display GUI elements, the SWT implementation accesses the native GUI libraries of the operating system using Java Native Interface (JNI) in a manner that is similar to those programs written using operating system-specific application programming interfaces (APIs). Programs that call SWT are portable, but the implementation of the toolkit, despite part of it being written in Java, is unique for each platform. The toolkit is free and open-source software distributed under the Eclipse Public License, which is approved by the Open Source Initiative.

History The first Java GUI toolkit was the Abstract Window Toolkit (AWT), introduced with Java Development Kit (JDK) 1.0 as one component of Sun Microsystems' Java platform. The original AWT was a simple Java wrapper library around native (operating system-supplied) widgets such as menus, windows, and buttons. Swing was the next generation GUI toolkit introduced by Sun in Java Platform, Standard Edition (J2SE) 1.2. Swing was developed to provide a richer set of GUI software components than AWT. Swing GUI elements are all-Java with no native code: instead of wrapping native GUI components, Swing draws its own components by using Java 2D to call low-level operating system drawing routines. The roots of SWT go back to work that Object Technology International (OTI), did in the 1990s when creating multiplatform, portable, native widget interfaces for Smalltalk, originally for OTI Smalltalk, which became IBM Smalltalk in 1993. IBM Smalltalk's Common Widget layer provided fast, native access to multiple platform widget sets while still providing a common API without suffering the lowest common denominator problem typical of other portable graphical user interface (GUI) toolkits. IBM was developing VisualAge, an integrated development environment (IDE) written in Smalltalk. They decided to open-source the project, which led to the development of Eclipse, intended to compete against other IDEs such as Microsoft Visual Studio. Eclipse is written in Java, and IBM developers, deciding that they needed a toolkit that had "native look and feel" and "native performance", created SWT as a Swing replacement.

Design

SWT is a wrapper around native code objects, such as GTK objects, Motif objects etc. Because of this, SWT widgets are often referred to as "heavyweight", evoking images of a light Java wrapper around a "heavy" native object. In cases where native platform GUI libraries do not support the functionality required for SWT, SWT implements its own GUI code in Java, similar to Swing. In essence, SWT is a compromise between the low-level performance and look and feel of AWT and the high-level ease of use of Swing. According to the Eclipse Foundation, "SWT and Swing are different tools that were built with different goals in mind. The purpose of SWT is to provide a common API for accessing native widgets across a spectrum of platforms. The primary design goals are high performance, native look and feel, and deep platform integration. Swing, on the other hand, is designed to allow for a highly customizable look and feel that is common across all platforms." It has been argued that SWT features a clean design, in part inspired by Erich Gamma of Design Patterns fame. SWT is a simpler toolkit than Swing, with less (possibly) extraneous functionality for the average developer. This has led some people to argue that SWT lacks functionality when compared to Swing. James Gosling, the creator of the Java language, has argued that SWT is too simple, and is a difficult toolkit to port to new platforms for the same reason that AWT once had porting problems: that it is too simple, too low level, and too tied to the Win32 GUI API, leading to problems adapting the SWT API to other GUI toolkits, such as Motif and OS X Carbon. Although SWT does not implement the popular model–view–controller (MVC) architecture used in Swing and multiple other high-level GUI toolkits, the JFace library, which is developed as part of the same Eclipse project, does provide a cross-platform, higher-level MVC abstraction atop SWT. Developers may choose to use JFace to provide more flexible and abstract data models for complex SWT controls such as trees, tables, and lists, or access those controls directly as needed.

Look and feel

SWT widgets have the same look and feel as native widgets because they often are the same native widgets. This is in contrast to the Swing toolkit where all widgets are emulations of native widgets. In some cases the difference is distinguishable. For example, the macOS tree widget features a subtle animation when a tree is expanded and default buttons have an animated pulsing glow to focus the user's attention on them. The default Swing version of these widgets does not animate. Since SWT is simply a wrapper around native GUI code, it does not require large numbers of updates when that native code is changed, providing that operating system vendors are careful not to break clients of their API when the operating systems are updated. The same cannot be said of Swing, which supports the ability to change the look and feel of the running application with "pluggable looks and feels". These enable emulating the native platform user interface using themes, which must be updated to mirror operating system GUI changes, such as theme or other look and feel updates. SWT aims for "deep platform integration", the Eclipse reference to SWT's use of native widgets. According to Mauro Marinillia of developer.com, "whenever one needs a tight integration with the native platform, SWT can be a plus". This deep integration can be useful in a number of ways, for example enabling SWT to wrap ActiveX objects on Microsoft Windows.

Programming

The following is a basic "Hello, World!" program using SWT. It shows a window (org.eclipse.swt.widgets.Shell) and a label.

Contrary to Swing, a org.eclipse.swt.widgets.Display class is necessary to access the underlying operating system, and its resources must be explicitly disposed of when they are no longer used.

Platform support

… excerpt ends here. Continue reading the full article.

Illustrations

Standard Widget Toolkit illustration
Standard Widget Toolkit: A demo application on Linux
A demo application on Linux
Standard Widget Toolkit: The same demo application on macOS
The same demo application on macOS
Standard Widget Toolkit: A simple GUI application using SWT running in a GTK environment
A simple GUI application using SWT running in a GTK environment
Standard Widget Toolkit: Vuze, a BitTorrent client which uses SWT
Vuze, a BitTorrent client which uses SWT

Worked examples

Example 1 — a first encounter with Standard Widget Toolkit

Start with the simplest possible case. Write down what Standard Widget Toolkit claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Standard Widget Toolkit before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Standard Widget Toolkit ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Standard Widget Toolkit

In research
Standard Widget Toolkit appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Standard Widget Toolkit in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Standard Widget Toolkit is common in secondary-school and first-year university syllabi. It links to neighbouring topics Eclipse (software), Eclipse software, Eclipse technology, so understanding it makes those chapters shorter.
In everyday life
Look for Standard Widget Toolkit outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Standard Widget Toolkit” →

How to study Standard Widget Toolkit in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Standard Widget Toolkit means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Standard Widget Toolkit out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Standard Widget Toolkit in simple terms?

The Standard Widget Toolkit (SWT) is a graphical widget toolkit for use with the Java platform. It was originally developed by Stephen Northover at IBM and is now maintained by the Eclipse Foundation in tandem with the Eclipse IDE.

Why does Standard Widget Toolkit matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Standard Widget Toolkit?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Standard Widget Toolkit.

Tags

  • Eclipse (software)
  • Eclipse software
  • Eclipse technology
  • Free computer libraries
  • Java (programming language) libraries
  • Software using the Eclipse Public License
  • Widget toolkits

Keep exploring