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 8953525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:06:56+00:00 2026-06-15T14:06:56+00:00

This is my dialog class: InputDialog which is opened with a button from another

  • 0

This is my dialog class: InputDialog which is opened with a button from another View. This Dialog contains a single Text input.

public class InputDialog extends Dialog{
   public InputDialog(Shell parentShell) {
      super(parentShell);
      // TODO Auto-generated constructor stub
   }

   @Override
   protected Control createDialogArea(Composite parent) {
       parent.setLayout(new GridLayout(1, false));

       Text txtName = new Text(parent, SWT.NONE);

       return super.createDialogArea(parent);
   }

   @Override
   protected void okPressed() {
       // TODO Auto-generated method stub
       super.okPressed();
   }
}

And this is how I open the dialog:

buttAdd.addSelectionListener(new SelectionListener() {

    @Override
    public void widgetSelected(SelectionEvent e) {
        // TODO Auto-generated method stub

        InputDialog dialog = new InputDialog(new Shell());
        dialog.open();
    }

    @Override
    public void widgetDefaultSelected(SelectionEvent e) {
        // TODO Auto-generated method stub

    }
});

How can I handle/read the returned or submitted value’s from the Dialog?

  • 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-15T14:06:57+00:00Added an answer on June 15, 2026 at 2:06 pm

    You can persist the entered value in a field within the dialog, then use a getter after the dialog closes.

    Since the InputDialog is blocking, you will have to check it’s return value.

    if (Window.OK == dialog.open()) {
        dialog.getEnteredText();
    }
    

    where

    public class InputDialog extends Dialog {
        private Text txtName;
        private String value;
    
        public InputDialog(Shell parentShell) {
            super(parentShell);
            value = "";
        }
    
        @Override
        protected Control createDialogArea(Composite parent) {
            parent.setLayout(new GridLayout(1, false));
    
            txtName = new Text(parent, SWT.NONE);
    
            return super.createDialogArea(parent);
        }
    
        @Override
        protected void okPressed() {
            value = txtName.getText();
        }
    
        public String getEnteredText() {
            return value;
        }
    }    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I remove a view from this dialog? I know I can remove
In my app, pressing a button activates a dialog box. This dialog box contains
I have this nice dialog view I set my UserInputDialog class to: <LinearLayout android:id=@+id/LinearLayout01
I have this custom dialog: public class MyProgressDialog extends Dialog { public MyProgressDialog(Context context)
The docs say this for the dismiss() method from the Dialog class: Dismiss this
I'm trying to create a dialog class in WPF. This class inherits from Window
I have some Dialog class via which I select files and/or directories. Within this
this is my custom dialog class: package com.WhosAround.Dialogs; import com.WhosAround.AppVariables; import com.WhosAround.R; import com.WhosAround.AsyncTasks.LoadUserStatus;
I've seen this dialog pop up from time to time when installing softwre and
i have created a custom dialog class public class NewPost extends Dialog { //

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.