I have a main shell and I tried creating a child shell but when I go to the design view in Swt Designer, the property editor shows two "(Shells)". This is confusing because I don't know which one is the main shell and which one is the child shell.
Here is the code:
- Code: Select all
public class Main extends Shell {
public static void main(String args[]) {
try {
Display display = Display.getDefault();
Main shell = new Main(display, SWT.SHELL_TRIM);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
// e.printStackTrace();
}
}
public Main(Display display, int style) {
super(display, style);
createContents();
}
protected void createContents() {
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
class Child extends Shell {
public Child(Display display, int style) {
super(display, style);
createContents();
}
protected void createContents() {
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
If I create the child shell without extending the shell class, Swt Designer correctly displays the name of the child shell in property editor.
Here is the code:
- Code: Select all
class childShell {
Shell child;
Shell parent;
childShell(Shell master) {
this.parent = master;
this.child = new Shell(Display.getCurrent(), SWT.SHELL_TRIM);
}
}
So, what is the best way to create a child shell?
Thanks.