1

Using Albireo, it's easy to see how to show a Swing dialog from SWT:

private AwtEnvironment awtEnv = AwtEnvironment.getInstance(Display.getCurrent);

...
// call from SWT thread
void showSwingMessageDialog(String msg) {
    awtEnv.invokeAndBlockSwt(new Runnable() {
        public void run() {
            Frame parentFrame = awtEnv.createDialogParentFrame();
            JOptionPane.showMessageDialog(parentFrame, msg);
        }
    }
}

I want to show an SWT dialog from AWT thread, i.e.

// call from AWT thread
void showSWTMessageDialog(String msg) {
    ???
}
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487

1 Answers1

3

I'm not sure, if I understand this question well, but when you are writing program with Albireo/SWT_AWT bridge, you use SWT normally and when you need, you can use Swing for some work (as this example on eclipse wiki shows).. So if you have your parent (most probably Shell instance) in some global attribute, you can just create SWT dialog whenever and wherever you need..

EDIT

For blocking the AWT thread, you could call invokeAndWait() method of SwingUtilities and inside the Runnable instance show the SWT dialog window..

Sorceror
  • 4,835
  • 2
  • 21
  • 35
  • I'm not sure, you'll have to probably try that.. Anyway, why do you want to block the thread? Maybe this small part of [wiki article](http://wiki.eclipse.org/Albireo_Documentation#Multiple_Event_Threads) will help you, or more deep (and longer) article [about SWT and AWT](http://www.eclipse.org/articles/article.php?file=Article-Swing-SWT-Integration/index.html) will help to answer the question.. – Sorceror Jul 21 '11 at 15:14
  • "Anyway, why do you want to block the thread?" The "Modal dialogs" section of the Eclipse Corner article explains why this is needed (but not how to do it). – Alexey Romanov Jul 22 '11 at 05:38