Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8619439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:20:22+00:00 2026-06-12T06:20:22+00:00

Why in the following code (part of a class that extends TitleAreaDialog ): @Override

  • 0

Why in the following code (part of a class that extends TitleAreaDialog):

@Override  
protected void createButtonsForButtonBar(Composite parent) {          
    super.createButtonsForButtonBar(parent);  
    this.getButton(IDialogConstants.OK_ID).addSelectionListener(new SelectionAdapter() {  
        @Override  
        public void widgetSelected(SelectionEvent e) {  
            okPressed();  
        }  
    });  
}  

@Override  
protected void okPressed() {  
    saveInput();  
    super.okPressed();  
}

private void saveInput(){  
    firstNameSelected = firstNameCombo.getText();  
    lastNameSelected = lastNameCombo.getText();      
}    

I get the following exception when I press the OK button:

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.Combo.getText(Combo.java:1006)

In line: firstNameSelected = firstNameCombo.getText(); of saveInput?
Why is the widget disposed on selection?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:20:23+00:00Added an answer on June 12, 2026 at 6:20 am

    Try removing the createButtonsForButtonBar(Composite parent) method completely. The dialog should call okPressed by itself.

    Moreover, I think calling super.okPressed() isn’t necessary. At least I never use it. Just call this.close() instead.

    Here is the simple template I use:

    public class OptionsDialog extends Dialog {
    
        public OptionsDialog(Shell parentShell)
        {
            super(parentShell);
            setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
            setBlockOnOpen(true);
        }
    
        protected Control createDialogArea(Composite parent) {
            Composite composite = (Composite) super.createDialogArea(parent);
    
            GridLayout layout = new GridLayout(1, false);
            layout.marginHeight = 5;
            layout.marginWidth = 10;
    
            composite.setLayout(layout);
    
            GridData gridData = new GridData();
            gridData.widthHint = 500;
    
            composite.setLayoutData(gridData);
    
            createContent();
    
            return composite;
        }
    
        private void createContent()
        {
            /* ADD WIDGETS */
        }
    
        protected void configureShell(Shell newShell)
        {
            super.configureShell(newShell);
            newShell.setText("Options");
        }
    
        public void okPressed()
        {
            /* SAVE VALUES */
            this.close();
        }
    
        /* GETTERS AND SETTERS/ */
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following is a part of my code for a project: public class Body extends
my problem is the following: This is a part of my HTML-Code: <form method='GET'
I have a class FourByFourBoard that extends GameBoard . I define the following fields:
I'm writing a custom web part that extends DataFormWebPart. public class MyCustomWebPart : DataFormWebPart{
So I have the following code: import java.lang.Thread; import java.lang.Integer; class MyThread extends Thread
Given the following code: using System.Collections.Generic; static class Program { static void Main() {
I am using the following code as part of an autocomplete script to avoid
Using linkedin-j , I have the following code in one part of my application
Ok - I have the following code - on the starred part I get
I have the following code in one cpp file which is part of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.