Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » org.eclipse.swt.SWTException: Widget is disposed(clicking on button for more than one time throws error)
org.eclipse.swt.SWTException: Widget is disposed [message #1001330] Wed, 16 January 2013 13:59 Go to next message
Mayur Mitkari is currently offline Mayur MitkariFriend
Messages: 1
Registered: January 2013
Junior Member
hello
i have following code for creating pop up message


Button ok = componentsRenderer.createButtonWidget(versionTreeComponentsShell, SWT.PUSH,
PropertyClass.getPropertyLabel(QTLConstants.OK_BUTTON));
Button cancel = componentsRenderer.createButtonWidget(versionTreeComponentsShell, SWT.PUSH,
PropertyClass.getPropertyLabel(QTLConstants.CANCEL_BUTTON));
ok.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
StringBuffer sbDefaultVersionSplitter = new StringBuffer();
String defaultVersionSplitterSelected = "";
if(versionSplitterCheckBoxList.size() > 0){
String[] defaultVersionSplitters = PropertyClass.getPropertyLabel(QTLConstants.VERSIONING_ASSISTENT_PAGE_SPLLITER).split(QTLConstants.MULTIPLE_EXTENSIONS_SPLITER);
for(Button cbButton : versionSplitterCheckBoxList){
if(cbButton.getSelection() && !cbButton.getText().equalsIgnoreCase(defaultVersionSplitters[3])){
// check is added for version number string equal to "<fileName><number>" i.e splitter is not present
if(!cbButton.getText().equalsIgnoreCase(defaultVersionSplitters[2])){
String tempVersionStringWithSplitter = cbButton.getText().substring(cbButton.getText().indexOf("_")+1,cbButton.getText().length());
String selectedSplitter = tempVersionStringWithSplitter.substring(0,tempVersionStringWithSplitter.indexOf("<"));

sbDefaultVersionSplitter.append(selectedSplitter);
sbDefaultVersionSplitter.append("|");
}
}
}//end of for loop
if(customVersionSplitterText.isEnabled() && customVersionSplitterText.getCharCount() > 0){
sbDefaultVersionSplitter.append(customVersionSplitterText.getText());
defaultVersionSplitterSelected = sbDefaultVersionSplitter.toString();
} else if(sbDefaultVersionSplitter.length() > 0 && (!customVersionSplitterText.isEnabled() || customVersionSplitterText.getCharCount() == 0)){
defaultVersionSplitterSelected = sbDefaultVersionSplitter.toString().substring(0, sbDefaultVersionSplitter.length()-2);
}
}//end of if loop
dataBean.setVersionSplitterSelected(defaultVersionSplitterSelected);
versionTreeComponentsShell.close();
}
});
cancel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
versionTreeComponentsShell.setVisible(false);
}
});


when i am clicking on "OK" button for more than one time its throwing following error

org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(SWT.java:4361)
at org.eclipse.swt.SWT.error(SWT.java:4276)
at org.eclipse.swt.SWT.error(SWT.java:4247)
at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340)
at org.eclipse.swt.widgets.Button.getSelection(Button.java:721)
at com.impact.qtl12.imports.UI.CSVWizard.FileInputPage$10.widgetSelected(FileInputPage.java:784)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at com.impact.qtl12.imports.UI.CSVFile.QTL$4.widgetSelected(QTL.java:427)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
at com.impact.qtl12.imports.UI.CSVFile.QTL.createShell(QTL.java:767)
at com.impact.qtl12.imports.UI.CSVFile.QTL.launch(QTL.java:826)
at com.impact.qtl12.imports.UI.CSVFile.QTL.main(QTL.java:847)

Re: org.eclipse.swt.SWTException: Widget is disposed [message #1007420 is a reply to message #1001330] Tue, 05 February 2013 19:17 Go to previous message
Vasanthi Sathyanarayanan is currently offline Vasanthi SathyanarayananFriend
Messages: 7
Registered: January 2013
Location: Bangalore, India
Junior Member
In your okbutton selection listener, there is a line:

versionTreeComponentsShell.close();

in which you are disposing the parent of the okbutton. (that is versionTreeComponentsShell)

> Because of the parent shell dispose call, the parent shell and its child widgets (Okbutton and others) get disposed. So any further access to any of these widgets will throw a "widget disposed" exception.

So make sure after the shell dispose call, you are not accessing the okbutton to avoid this exception.


Regards,
Vasanthi
Previous Topic:How enable and disable buttons using event in SWT.
Next Topic:GridData width hint hides field
Goto Forum:
  


Current Time: Thu Apr 25 09:25:00 GMT 2024

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

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

Back to the top