SWT/JFace in Action
eBook - ePub

SWT/JFace in Action

GUI Design with Eclipse 3.0

Matthew Scarpino, Laurent Mihalkovic, Stanford Ng, Stephen Holder

Compartir libro
  1. 496 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

SWT/JFace in Action

GUI Design with Eclipse 3.0

Matthew Scarpino, Laurent Mihalkovic, Stanford Ng, Stephen Holder

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

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.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es SWT/JFace in Action un PDF/ePUB en línea?
Sí, puedes acceder a SWT/JFace in Action de Matthew Scarpino, Laurent Mihalkovic, Stanford Ng, Stephen Holder en formato PDF o ePUB, así como a otros libros populares de Informatica y Programmazione in Java. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Editorial
Manning
Año
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...

Índice