Java - SWT ( Standard Widget Toolkit ) / JFACE - Interview Questions and Answers


1. What is SWT ?

Ans. Standard Widget Toolkit (SWT): SWT is an open source widget tool kit for developing rich, efficient and portable GUI applications.

2. Which is the highest level container which contains other widgets in SWT ?

Ans. Shell

3. Can we run Swing objects using SWT ?

Ans. Yes

4. What are the key components of SWT applications ?

Ans. The Display and Shell classes are key components of SWT applications.

A org.eclipse.swt.widgets.Shell class represents a window.

The org.eclipse.swt.widgets.Display class is responsible for managing event loops, fonts, colors and for controlling the communication between the UI thread and other threads. Display is the base for all SWT capabilities.

5. Are SWT Widgets automatically Gabage collected ?

Ans. SWT widgets are not automatically garbage collected. If you release an SWT widget, you have to call its dispose() method.

Disposing a widget releases all it's children.

6.How do we do event handling using SWT ?

Ans. We do it by registering listeners for respective widgets

7. Explain Layout Managers in SWT ?

Ans. A layout manager is responsible for arranging the user interface components of a container, e.g. a Composite, on the screen. SWT offers several standard layout managers.

Following are the layout managers offered by SWT

AbsoluteLayout
FillLayout
RowLayout
GridLayout
FormLayout

8. Have you worked with the TreeViewer ? If yes , explain

Ans. The TreeViewer class provides viewer support for displaying trees. This widget is used to display parent-child information with buttons to expand and collapse the tree.
We have to create and specify the LabelProvider and Content Provider classes. In the respective classes we specify the parent and child objects and their relationship.

9. Which class is used to create buttons and how many classes we have to create different button types ?

Ans. Only a single class ie Button is used to create all button types. We distinguish among different types by specifying the style while creating a new button object.

10. If we need to change the cell text in tableviewer or tree viewer , which file should we make the change in ?

Ans. LabelProvider 


Submit a Question today. We will publish it with credits to you.