13

Simply put: Is there any way to create non-modal JFace dialog? I've tried calling setShellStyle to no avail. If I remember right this isn't a problem in swing - is this a shortcoming of SWT, or am I just misusing the widget?

TIA

javamonkey79
  • 17,443
  • 36
  • 114
  • 172

2 Answers2

26

Using

setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE);
setBlockOnOpen(false);

seems to be the practice. This doesn't work for you?

Bala R
  • 107,317
  • 23
  • 199
  • 210
  • I haven't tried it exactly this way. I will try it and get back to you. – javamonkey79 Apr 26 '11 at 21:18
  • I am pretty sure this is it, I had another issue going on that was clouding it. Where did you find this practice? – javamonkey79 Apr 26 '11 at 21:25
  • from [this post](http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg09439.html) but I have used something similar in the past and has worked. – Bala R Apr 26 '11 at 21:27
  • Ah man! The difference between googling: 'non-modal' and 'modeless'. Thanks, accepted and +1 for the forum follow up :) Thanks! – javamonkey79 Apr 26 '11 at 21:31
12
@Override
protected void setShellStyle(int newShellStyle) {           
    super.setShellStyle(SWT.CLOSE | SWT.MODELESS| SWT.BORDER | SWT.TITLE);
    setBlockOnOpen(false);
}

The above code will solve the problem..

javanna
  • 59,145
  • 14
  • 144
  • 125
Abdul Rehman
  • 129
  • 1
  • 2
  • Highly recommend. Thanks :) – Asakura Mar 26 '16 at 21:09
  • It will solve the problem but I just want to point out that it is kind of hacky, because you ignore the newShellStyle completely. In a few years you might add a call to setShellStyle() in your application code and you search for hours why that call will not change anything. – Stefan Winkler May 25 '20 at 08:00