Take the 2-minute tour ×

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.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
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?

share|improve this question
Is NX's GUI using SWT? If yes, look for API returning its shell, or any of the controls (from which you can get the shell). If no, this is not possible (AFAIK). –  Alexey Romanov Jan 30 '13 at 19:51
No, NX is not an SWT application. Looks like I might be stumped then. –  Graham Feb 4 '13 at 13:25
add comment

1 Answer

when you create your window, there is a Shell style that bring your window always on the top :

Shell sShell = new Shell(Display.getCurent(),SWT.ON_TOP);

share|improve this answer
add comment

Your Answer


