Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Browser widget example. CloseWindowListener?
Browser widget example. CloseWindowListener? [message #445761] Wed, 10 November 2004 17:51 Go to next message
Jerome Jacobsen is currently offline Jerome JacobsenFriend
Messages: 6
Registered: July 2009
Junior Member
I've been studying and playing around with the SWT Browser Example.

I'm unsure what the following code (in the initialize method) accomplishes:

browser.addCloseWindowListener(new CloseWindowListener() {
public void close(WindowEvent event) {
Browser browser = (Browser)event.widget;
Shell shell = browser.getShell();
shell.close();
}
});

If I comment the code out and run the browser (Windows 2000, MSIE 6) it
works fine. If I leave the code in it works fine too. So what purpose does
the above listener serve?
Re: Browser widget example. CloseWindowListener? [message #445764 is a reply to message #445761] Wed, 10 November 2004 18:49 Go to previous message
Ron Capelli is currently offline Ron CapelliFriend
Messages: 10
Registered: July 2009
Junior Member
Jerome Jacobsen wrote:
> I'm unsure what the following code (in the initialize method)
> accomplishes:
>
> browser.addCloseWindowListener(new CloseWindowListener() {
> public void close(WindowEvent event) {
> Browser browser = (Browser)event.widget;
> Shell shell = browser.getShell();
> shell.close();
> }
> });
>
> If I comment the code out and run the browser (Windows 2000, MSIE 6)
> it works fine. If I leave the code in it works fine too. So what
> purpose does the above listener serve?

The initialize() method in the SWT Example Browser is invoked for new
browser popup windows. If the popup uses javascript window.close() to
close the popup browser, the parent Shell is not automatically closed.
The CloseWindowListener close() method is provided to close the parent
Shell.

To see an example, go to http://www.cnn.com and look for any of the
gallery links. These open popup windows with a "close window [x]"
button in the upper right. Try that with the CloseWindowListener code
commented out to see the difference in behavior...

....Ron Capelli (Austin TX)
Previous Topic:building one Image from severall
Next Topic:open source SWT HtmlEditor
Goto Forum:
  


Current Time: Wed Nov 25 00:26:49 GMT 2020

Powered by FUDForum. Page generated in 0.01419 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top