 Subclasses of the SWT Shell class can be
created using the SWT Shell wizard. The wizard can be
selected from the drop down WindowBuilder wizard menu or from the
Eclipse New wizard.
To use the wizard, select the project source folder and package
to contain the class. Then enter the class name and hit the Finish
button. The org.eclipse.swt.widgets.Shell class is the default
superclass. You can select an alternative superclass by entering
its name into the Superclass field or by choosing it via
the bottom Browse button.
You can also choose org.eclipse.ercp.swt.mobile.MobileShell as
the default superclass.

The wizard generates the following code including a main() method.
import
org.eclipse.swt.widgets.Display;
import
org.eclipse.swt.widgets.Shell;
public
class
SwtShell extends
Shell {
public
static
void
main(String[] args) {
try
{
Display display = Display.getDefault();
SwtShell shell =
new
SwtShell();
shell.open();
shell.layout();
while
(!shell.isDisposed()) {
if
(!display.readAndDispatch()) {
display.sleep();
}
}
}
catch
(Exception e) {
e.printStackTrace();
}
}
public
SwtShell() {
createContents();
}
protected
void
createContents() {
setText("eSWT
Application");
setSize(450, 300);
}
@Override
protected
boolean
isValidSubclass() {
// Disable the
check that prevents subclassing of SWT components
return
true;
}
}

If org.eclipse.ercp.swt.mobile.MobileShell is chosen as the
default superclass, the following code is generated:
import
org.eclipse.ercp.swt.mobile.MobileShell;
import
org.eclipse.swt.SWT;
import
org.eclipse.swt.widgets.Display;
public
class
SwtMobileShell extends
MobileShell {
public
static
void
main(String[] args) {
try
{
Display display = Display.getDefault();
SwtShell shell =
new
SwtMobileShell();
shell.open();
shell.layout();
while
(!shell.isDisposed()) {
if
(!display.readAndDispatch()) {
display.sleep();
}
}
}
catch
(Exception e) {
e.printStackTrace();
}
}
public
SwtMobileShell() {
super(SWT.SHELL_TRIM);
createContents();
}
protected
void
createContents() {
setText("eSWT
Application");
setSize(450, 300);
}
@Override
protected
boolean
isValidSubclass() {
// Disable the
check that prevents subclassing of SWT components
return
true;
}
}
When editing SWT Shells, all of the standard SWT layouts,
containers, widgets and menus are available. Custom or third party
controls may be added via the
Choose
Component command.
|