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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:07:58+00:00 2026-06-10T11:07:58+00:00

According to another discussion here, I try to open a modal view like so:

  • 0

According to another discussion here, I try to open a modal view like so:

public void widgetSelected(SelectionEvent e) {

    final Shell dialogShell = new Shell(ApplicationRunner.getApp()
            .getShell().getDisplay(), SWT.PRIMARY_MODAL | SWT.SHEET);

    dialogShell.setLayout(new FillLayout());

    Button closeButton = new Button(dialogShell, SWT.PUSH);
    closeButton.setText("Close");
    closeButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            dialogShell.dispose();
        }

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

        }
    });
    dialogShell.setDefaultButton(closeButton);
    dialogShell.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            System.out.println("Modal dialog closed");
        }
    });
    dialogShell.pack();
    dialogShell.open();
}

It opens the desired window, but it’s not modal. I can access the main shell and open another instance of the same modal dialog. Can anybody point me in the right direction?

Thanx, Marcus

  • 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-10T11:08:00+00:00Added an answer on June 10, 2026 at 11:08 am

    I would highly recommend creating your own JFace Dialog by extending org.eclipse.jface.dialogs.Dialog rather than creating your own shell with buttons.
    Here is a really good tutorial on this.

    Within the contructor you can call setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.OK | SWT.APPLICATION_MODAL); which will make this dialog completely modal, if you call the constructor with your main shell as the parameter. Like this:

    public CheckboxDialog(Shell parentShell) {
        super(parentShell);
        setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.OK | SWT.APPLICATION_MODAL);
        setBlockOnOpen(true);
    }
    

    where parentShell is the main shell of your GUI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to base one component's x and y cooridnates according to another,
According to another question, you can view your skin with this code: <applet code=net.minecraft.skintest.ModelPreviewApplet
According to the answers to another question , the VB user interface cannot be
I'm in the need of sorting an array according to another one, I've asked
According to this answer on another question, the Collapsed event of a ContextMenu is
Another way to ask this question is: what is Inversion of Control according to
According to another question I can select individual XML fields with a YQL query
I'm having trouble sorting an array according to another array. I've tried usort, uksort
According to Android's Activity lifecyle , method Activity.onPause() is called only if another activity
I don't think this is not another resize iframe according to content height question.

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.