0

In SWT: do you know which is the Event to listen to, in order to identify that the SWT "Shell" object has been just opened and so open a new Shell at startup?

Thank you in advance.

paulsm4
  • 114,292
  • 17
  • 138
  • 190
navy1978
  • 1,411
  • 1
  • 15
  • 35
  • OK: I can appreciate your frustration about asking what *seemed* to be a perfectly reasonable question. I didn't downvote you. And frankly, I didn't know that SWT *had* a "Shell" object, much less that's what you were talking about. FYI, in some examples the class used to be named "SwtShell". In the current Javadoc, it's simply "Shell". My bad :(. Q: Does it have an "Event" you can "listen for"? I don't know. I'm going to revisit the SWT Javadoc, and look in "Shell's" class hierarchy to see. – paulsm4 Jan 07 '19 at 21:07
  • And I appreciate your honesty and your effort to find a solution, I already know there is this Event: (ShellEvent) https://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fevents%2FShellEvent.html and also "SWT.Show" but they don't seem to work as expected... – navy1978 Jan 07 '19 at 21:13
  • OK, then. The next step is for one or both of us to write an [MCVE](https://stackoverflow.com/help/mcve). I'll be referring to these links: https://stackoverflow.com/questions/7387818/, http://www.java2s.com/Tutorial/Java/0280__SWT/ShellEvents.htm and https://www.programcreek.com/java-api-examples/?api=org.eclipse.swt.events.ShellListener. Please update your post if you finish first, and still have questions. Otherwise, if you figure it out, please post a "response" and "accept" it. I'll do the same if I finish before that :) – paulsm4 Jan 07 '19 at 21:19

1 Answers1

2

Most things use the first resize event on the Shell (there may be several resizes so be careful to only trigger on the first).

shell.addListener(SWT.Resize, event ->
   {
      ... resize code
   });

(Java 8 and above code)

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • 1
    As always Greg is the best! :) Very strange there is no a specific event to listen to... – navy1978 Jan 07 '19 at 21:27
  • @greg-449: you beat me to an answer - I had't even gotten my SWT project started yet :) Thank you. Also: please upvote navy1978's question, so he doesn't have that ugly-looking - and completely unwarranted - "-1". – paulsm4 Jan 07 '19 at 21:31
  • 1
    There are all sorts of events (including SWT.Show and SWT.Skin) but it isn't very well documented when they occur. – greg-449 Jan 07 '19 at 21:33
  • @greg-449 I tried with SWT.Show but with no luck, I even didn't know SWT.skin was there... :). – navy1978 Jan 07 '19 at 21:35