SWT/JFace in Action
eBook - ePub

SWT/JFace in Action

GUI Design with Eclipse 3.0

Matthew Scarpino, Laurent Mihalkovic, Stanford Ng, Stephen Holder

Partager le livre
  1. 496 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

SWT/JFace in Action

GUI Design with Eclipse 3.0

Matthew Scarpino, Laurent Mihalkovic, Stanford Ng, Stephen Holder

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Covering Eclipse's new capability for building graphical user interfaces with version 3.0, the Standard Widget Toolkit (SWT) and JFace, this guide demonstrates how these award-winning tools have received broad support for creating desktop applications. Theory and practical examples reveal how to build GUIs that combine the look and feel of native interfaces with the platform independence of Java. This guide also shows how SWT makes use of the widgets provided by the operating system and describes how these components can be associated with events, containers, and graphics. With this knowledge, programmers can build fully featured user interfaces that communicate directly with the underlying platform. JFace's ability to simplify and organize the process of GUI design is then demonstrated, enabling developers to modify and adapt components, and separate their information from their appearance.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que SWT/JFace in Action est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  SWT/JFace in Action par Matthew Scarpino, Laurent Mihalkovic, Stanford Ng, Stephen Holder en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatica et Programmazione in Java. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Éditeur
Manning
Année
2004
ISBN
9781638354949

Chapter 1. Overview of SWT and JFace

This chapter covers
  • The purpose of SWT and JFace
  • The reasons for their creation
  • How the two libraries differ from Swing
  • Licensing and platform support
In March 2004, the Java Developer’s Journal announced the results of its Readers’ Choice Award for Best Java Component. More than 15,000 developers voted for one of many Java toolsets, including offerings from such established names as Oracle and Apple. But in the end, Eclipse’s Standard Widget Toolkit (SWT) won handily, just as it did in 2003. Despite their late entry into the field of Java development, Eclipse and SWT have also won awards and recognition from JavaWorld, JavaPro, and LinuxWorld.
This well-earned applause goes a long way in showing the impact these tools have made on Java development. Java programmers around the world have embraced the power and versatility of SWT and JFace, deploying new plug-ins and standalone applications with each passing day. The goal of this book is to show you how this toolset functions and how you can use these tools for your own applications.
In particular, you’ll be able to
  • Develop SWT/JFace-based applications with hands-on code examples
  • Create customized graphics with SWT’s built-in graphical context
  • Understand the structure and methodology behind the SWT/JFace API
  • Further your knowledge of GUI (graphical user interface) design
  • Build and deploy SWT/JFace applications for Eclipse and standalone usage
Most important, GUI development should be fun! No other branch of programming provides the same satisfaction as watching a new graphical interface spring to life. Therefore, we’ll intersperse the theory of SWT and JFace with example code showing practical GUI development.
But before we start programming, we need to show you what this new technology is all about and what tasks it will help you perform.

1.1. What is SWT/JFace?

Although we refer to SWT and JFace as tools or toolsets, they’re essentially software libraries. They consist of packages that contain Java classes and interfaces. But what makes these components so special is that you can combine them to form GUIs. And not just any GUIs, either! Your applications will run quickly, make effective use of computer memory, and, like chameleons, assume the look and feel of whichever Java-supported operating system they run on. No other GUI-building library can say that.
Although SWT and JFace accomplish the same goal, they follow different philosophies in creating user interfaces. Our favorite analogy involves automobile transmissions. SWT development is like using a standard transmission: It gives you greater control and access to the system internals, but it’s more complicated to use. JFace, on the other hand, resembles an automatic transmission: It does most of the work for you, but you lose flexibility.
Of course, the truth is more complicated than any analogy. So, let’s investigate these two libraries in greater depth.

1.1.1. Building GUIs with SWT

Every operating system contains a number of graphical components that make up its default user interface. These include buttons, windows, menus, and everything else you see on your computer screen. The goal of SWT is to give you, the Java programmer, direct access to these components so that you can configure and position them however you like.
You don’t have to worry about the end user’s operating system. When you add an SWT Button object to your application, it will look and act like a Windows button on Windows, a Macintosh button on Macintosh, and a Linux button on a Linux system. Users will think that you wrote the GUI specifically for their machines, and they’ll have no idea that you wrote the code only once using SWT.
In addition to graphical components, SWT also provides access to events. This means you can keep track of what buttons your users have clicked and which menu items they’ve selected. This powerful capability makes it possible to receive and respond to nearly every form of user input, and we’ll spend a great deal of time showing how this works.
Finally, if you want to add graphics to your application, SWT provides a large set of tools for creating images, working with new fonts, and drawing shapes. This feature not only allows you to build new graphics, but also lets you control how, when, and where they’re displayed in your GUI. This book will show you how SWT manages colors, drawings, fonts, and images, and will present a great deal of example code.
SWT provides a wealth of capabilities for building user interfaces, but as you’ll see in this book, the code can become lengthy and complex. For this reason, the Eclipse designers built a second library for GUI development: JFace.

1.1.2. Simplifying GUI development with JFace

Rather than write the same SWT code over and over again, the designers of the Eclipse Workbench created JFace. This library provides shortcuts around many of the tasks that can be time-consuming using SWT alone. But JFace is not a replacement for SWT, and many GUIs will need features from both toolsets.
An important example of JFace’s increased efficiency involves events. In many user interfaces, you may have different events, such as button clicks, keystrokes, or menu selections, that all perform the same function. In SWT, each event needs to be received and handled separately. But JFace allows you to combine them into a single object, so you can concern yourself with the event’s response instead of the component that triggered it. This simple but powerful concept makes it possible to add context menus, toolbars, and palettes to your GUIs without adding a lot of code.
JFace is also helpful when you’re building large GUIs that require multiple windows and graphics. It provides registry classes that help you organize SWT components and manage their memory allocation. For example, in SWT, you need to specifically create and deallocate every Font and Image in your application. But with JFace, you can use built-in FontRegistry and ImageRegistry objects to take care of these tedious concerns for you.
Now that you understand the basic characteristics behind these two libraries, we need to dig a little deeper and show you the concepts behind their design. This discussion will explain why SWT/JFace GUIs are so fast, why they can take the appearance of whatever operating system they run on, and why they were created in the first place.

1.2. Looking under the hood

Adding components, events, and graphics to a user interface isn’t a new idea. Therefore, to see why the SWT/JFace toolset has caused such a stir, you need to understand what its designers were thinking. This means investigating the principles behind Java GUI development and how these libraries make use of them.
But before we can investigate SWT/JFace in depth, we need to introduce Swing. SWT and JFace were created in response to this library, and by understanding the contrast between the two design philosophies, you’ll better appreciate how SWT and JFace function. Further, in addition to recognizing the trade-offs between Swing and SWT/JFace, you’ll be able to participate in the passionate debates concerning the two.

1.2.1. The old standby: Swing

When Sun released the Swing library in 1998, the Java community was delighted. Finally, Sun had backed up its “Write Once, Run Anywhere” credo with a toolset capable of building platform-independent user interfaces. Swing quickly became the most popular tool for creating GUIs in Java.
But as time went by, many developers became discontented. The qualities that made Swing so attractive initially also made for complex development and slow operation. For this reason, Java GUIs have found little use in desktop applications.
Swing rendering
In order to ensure consistent appearance and operation across operating systems, Swing takes complete control of rendering its user interfaces...

Table des matiĂšres