TitleAreaDialog: Widgets disposed after click on the OK-Button [message #490423] |
Thu, 08 October 2009 15:39 |
Michelle Davidson Messages: 41 Registered: August 2009 |
Member |
|
|
Hello,
I have a JFace TitleAreaDialog, which change some properties for a given person.
In this dialog there are some textfields and some radio-Buttons.
I generate the OK and Cancel Button in the methode createButtonsForButtonBar().
@Override
protected void createButtonsForButtonBar(Composite parent) {
okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
okButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
person.setName(name.getText());
....
setReturnCode(OK);
close();
}
});
cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
cancelButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setReturnCode(CANCEL);
close();
}
});
}
But the problem is, when I click the ok Button and want to set the properties for the person., all textfields, radiobuttons are disposed and I don't get any values.
What is the reason for that, and what must I changed to set the values after click on the ok-Button.
|
|
|
Re: TitleAreaDialog: Widgets disposed after click on the OK-Button [message #490447 is a reply to message #490423] |
Thu, 08 October 2009 16:43 |
Eclipse User |
|
|
|
Originally posted by: evelyne.rien.com
You can override okPressed() like this :
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
protected void okPressed() {
person.setName(name.getText());
....
super.okPressed();
}
Don't call super.okPressed() if you want to cancel validation on some
controls (empty name for example).
It works for me when i'm subclassing JFace Dialog.
BTW : like okPressed(), okCancel() is called on Cancel Button.
Evelyne.
"Michelle Davidson" <michelle.davidson@gmx.de> a
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03383 seconds