Click here to Skip to main content
14,428,653 members
Rate this:
Please Sign up or sign in to vote.
See more:
I'm using a commercial CAD/CAM system (NX, formally Unigraphics). This has an API that I can develop against (using Java). It allows me to create a JAR and execute it from inside the normal NX UI. Now I want to use SWT to create a dialog for the users to interact with.
I can create a Shell and pass it the default Display and the window pops up perfectly. The code I have so far is as follows:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new RowLayout());

final Label label = new Label(shell, SWT.NONE);
label.setText("Hello, World!");

Button button = new Button(shell, SWT.PUSH);
button.setText("Create lines");
button.addSelectionListener(new SelectionListener() {
	public void widgetDefaultSelected(SelectionEvent arg0) {

	public void widgetSelected(SelectionEvent event) {

while (!shell.isDisposed())
	if (!display.readAndDispatch())

The SWT window that appears does not seem to be parented by the NX window, so if the user clicks in the NX window the SWT window disappears behind it.
What I think I need to do is get the Display (or maybe the Shell?) of the NX window and pass that to my Shell, but I can't seem to find out how to do that.
I've Googled till my head hurts but all the "re-parenting", "set shell", "make modal" searches all talk about child Shells inside an existing parent SWT Shell.
Anyone got any ideas if this is even possible?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I don't know if the NX System will even recognize the running shell of your SWT.

What you can do is to place the SWT part topmost:

this.setShellStyle( SWT.ON_TOP);

That should keep the SWT in front layer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100