Chapter 2, Creating Views with SWT

Pop quiz – understanding views

Q1

In the Eclipse 3.x model, views must be subclasses of ViewPart. In the Eclipse 4.x model, parts do not need to have an explicit superclass.

Q2

In the Eclipse 3.x model, views are registered via an org.eclipse.ui.views extension point in the plugin.xml file.

Q3

The two arguments that most SWT objects have are a Composite parent and an integer flags field.

Q4

When a widget is disposed, it will have its native resources released to the operating system. Any subsequent actions will throw an SWTException with a Widget is disposed message.

Q5

The Canvas has many drawing operations; to draw a circle, use drawArc() and specify a full orbit.

Q6

To receive drawing events, a PaintListener must be created and associated with the control by using the addPaintListener method.

Q7

UI updates not on the UI thread will generate an SWTException with an Invalid thread access error.

Q8

To perform an update on a widget from a non-UI thread, use the asyncExec() or syncExec() methods from Display (3.x) or UISynchronize (4.x) to wrap a runnable that will run on the UI thread.

Q9

SWT.DEFAULT is used to indicate default options in the flags parameter that is passed to the construction of an SWT widget.

Q10

Create a RowData object with the given size, and associate it with each Widget.

Pop quiz – understanding resources

Q1

Resource leaks occur when an SWT resource is acquired from the OS, but then not returned to it via a dispose() method prior to the object being garbage collected.

Q2

The different types of resources are Color, Cursor, Font, GC, Image, Path, Pattern, Region, TextLayout, and Transform.

Q3

Run the Eclipse instance in tracing mode with org.eclipse.ui/debug and org.eclipse.ui/trace/graphics set, specified in a debug file and launched with -debug.

Q4

Use the displayed data to get the object's arrays, and iterate through them.

Q5

The right way is to register a dispose listener with the view, and the wrong way is to override the dispose method.

Pop quiz – understanding widgets

Q1

Use the setFocus() method to set the focus on a particular widget.

Q2

Invoking redraw() will allow the widget to redraw itself.

Q3

The Combo can have a SelectionListener associated with it.

Q4

The widgetDefaultSelected() is what is called when the default value is used, typically an empty value.

Pop quiz – using SWT

Q1

Use the Tray and TrayItem widgets.

Q2

The SWT.NO_TRIM style means don't draw the edges of the window, or the close/maximize/minimize buttons.

Q3

Use setAlpha() to control a widget's transparency, including Shell.

Q4

Use setRegion() with a path describing the shape.

Q5

A group allows you to group things together with a standard item.

Q6

Most Composite use a null LayoutManager by default; it's only Shell and Dialog that have a non-default value.

Q7

Use a ScrolledComposite.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset