Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Capturing the closing event of a window that has SWT components in it
Capturing the closing event of a window that has SWT components in it [message #444565] Thu, 14 October 2004 21:11 Go to next message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Hi,

I have a class that has the below open() method. This class does NOT
inherit any GUI class. How would I catch the close event when the user
click the 'X' at the top-right corner of the window? (I am using SWT on
WINDOWS XP.) Thanks!

public void open()
{
m_display = Display.getDefault();
createContents();
m_shell.layout();
m_shell.open();
while (!m_shell.isDisposed())
{
if (!m_display.readAndDispatch())
m_display.sleep();
}

}
Re: Capturing the closing event of a window that has SWT components in it [message #444566 is a reply to message #444565] Thu, 14 October 2004 21:55 Go to previous messageGo to next message
John Arthorne is currently offline John ArthorneFriend
Messages: 176
Registered: July 2009
Senior Member
Use:

m_display.addListener(SWT.Close, yourListener);
--

AL wrote:
> Hi,
>
> I have a class that has the below open() method. This class does NOT
> inherit any GUI class. How would I catch the close event when the user
> click the 'X' at the top-right corner of the window? (I am using SWT on
> WINDOWS XP.) Thanks!
>
> public void open()
> {
> m_display = Display.getDefault();
> createContents();
> m_shell.layout();
> m_shell.open();
> while (!m_shell.isDisposed())
> {
> if (!m_display.readAndDispatch())
> m_display.sleep();
> }
>
> }
>
Re: Capturing the closing event of a window that has SWT components in it [message #444568 is a reply to message #444566] Fri, 15 October 2004 00:33 Go to previous message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Thanks for pointing me to the right direction...It was more of the below...

m_shell.addShellListener(new ShellAdapter()
{
public void shellClosed(ShellEvent e)
{
dispose();
}
});

John Arthorne wrote:
> Use:
>
> m_display.addListener(SWT.Close, yourListener);
> --
>
> AL wrote:
>
>> Hi,
>>
>> I have a class that has the below open() method. This class does NOT
>> inherit any GUI class. How would I catch the close event when the
>> user click the 'X' at the top-right corner of the window? (I am using
>> SWT on WINDOWS XP.) Thanks!
>>
>> public void open()
>> {
>> m_display = Display.getDefault();
>> createContents();
>> m_shell.layout();
>> m_shell.open();
>> while (!m_shell.isDisposed())
>> {
>> if (!m_display.readAndDispatch())
>> m_display.sleep();
>> }
>> }
>>
>
Previous Topic:Fill Layout and Sash question
Next Topic:How to do rich, printable, dynamic forms
Goto Forum:
  


Current Time: Fri Apr 19 14:48:42 GMT 2024

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

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

Back to the top