SWT JFace Interview Preparation Guide
Download PDF

SWT JFace job interview questions and answers guide. The one who provides the best SWT JFace answers with a perfect presentation is the one who wins the interview race. Learn SWT JFace and get preparation for the job of SWT JFace

14 SWT JFace Questions and Answers:

1 :: Explain SWT and JFace?

Standard Widget Toolkit (SWT):

SWT is an open source widget tool kit for developing rich, efficient and portable GUI applications. It was originally developed by IBM and being maintained by Eclipse Foundation along with Eclipse IDE. It is an alternative to AWT and Swing. To display the elements, it implements the operating system GUI libraries by using Java Native Interface. The SWT applications are portable and unique for each platform.

The need of SWT is to provide a common API for accessing different operating system / platform specific widgets. The goal for designing of SWT is high performance, native OS look and feel, and platform integration. Swing on the other hand, designed to allow for a highly customizable look and feel that is common across different platforms.

JFace:
A User Interface project developed by Eclipse to handle most commonly used User Interface tasks. It is window based system independent in both implementation and API. It is designed to work with SWT. JFace is included with images, text, dialog, wizard, images, font registries and progress reporting for long running operations.

JFace has two mechanisms – namely action and viewing.

The mechanism of actions allows the commands to be defined independently by the user from the exactness of whereabouts in the User Interface.
The mechanism of viewing is based on the adapters for certain SWT widgets, which simplifies the application presentation data structured with lists, tables or trees.

Eclipse runtime kernel is connected with few classes that have JFace. It can be a common practice to extract JFace and SWT to be used for stand-alone java applications which is not based on the Eclipse runtime.

2 :: What is ImageRegistry?

The mapping between symbolic image names and SWT image objects is maintained by the ImageRegistry class until the SWT image objects are needed. It owns all the images registered with it and automatically disposes them when the SWT Display that creates the images is disposed.

3 :: What is FontRegistry?

The FontRegistry maps between symbolic font names and SWT fonts. It owns all the fonts registered with it and automatically disposes them when the SWT Display that creates the fonts is disposed.

4 :: What is Dialog?

Dialogs are used to communicate the information from the user or to the user. The following are the different types of messages:

The MessageDialog displays information to the user
The InputDialog accepts the input from the user in the form of text
The ErrorDialog displays one or more errors to the user.

5 :: What is Wizard?

A wizard can be used to create new java classes, projects, files and folders. Wizards provide step by step process to create these elements. A well defined wizard is targeted to simplify user tasks and increase productivity. Wizard is meant to take out the hassle of creating repetitive and tedious tasks.

6 :: What is Action Mechanism?

Actions are tasks for various users operations such as clicks on menus, toolbars, status lines etc. In order to support these actions the action mechanism is implemented. There are listeners and managers for each of these actions.

7 :: What is Viewers?

Viewers are used to display objects using different SWT widgets. Types of viewers are as follows:

The ListViewer uses the SWT List widget to display the object. A simple list of elements can be created by using ListViewer.
The CheckboxTableViewer uses the SWT widget to display the objects of checkboxes.
The CheckboxTreeViewer uses the SWT table control with checkboxes on each node.
The CheckboxTreeViewer uses the SWT Tree control with checkboxes on each node.
The TableTreeViewer uses the SWT Table Tree control.
TableViewer, uses the SWT TableViewer control.
TreeViewer, uses the SWT TreeViewer control.

8 :: Explain Editors?

Using JFace Text framework, sophisticated editors such as XML editors and text editors can be developed. Any application needs editors to author the designated code. For example XML file needs tags to be written a flat text file. A program needs editor to author the code. By using different development template these editors can be plugged in and developed

9 :: What are the advantages offered by SWT/JFace?

Advantages of SWT:

Provides backend by providing native look with backend widgets by supporting Swing programming model.
SWT could run Swing native objects which enables SWT to run on any Swing support platform.
SWT based application loads faster compared to Swing applications
The memory usage is smaller in SWT as it uses the shared libraries. The shared library loads only once for all SWT applications.
Provides the exact platform look and feel. Even with the skinned desktop, it looks and feel is also skinned.
Provides different styles for different types of menus

10 :: Define Autoboxing with an example?

The automatic conversion of primitive int type into a wrapper class object is called autoboxing. It does not require to type cast the int value. The modification of primitive wrapper objects is done directly. The following example illustrates autoboxing:

int number;
Integer intObject;
number = 1;
intObject = 2;
number = intObject;
intObject = number;