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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:27:57+00:00 2026-06-10T08:27:57+00:00

I am trying to create a base dialog class using SWT and JFace: public

  • 0

I am trying to create a base dialog class using SWT and JFace:

 public class AplotBaseDialog extends TitleAreaDialog

I am confused about how to layout the dialog?

Doing it in Swing I would have a createDialog method. Then in that method I would add Components that was JPanel methods. Then add the components to my centerPanel. Which was the base dialog. Each Panel method had their own layout.

This is a very simple example (Pseudo Code)

public void createDialog() {
   Component selectionsPanel = createTableArea();
   Component buttonPanel = OKCancelButtons();
   JPanel centerPanel = new JPanel();
   centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS));
   centerPanel.add(selectionsPanel);
   centerPanel.add(buttonPanel);
   getContentPane().add(centerPanel);
   this.pack();
   centerPanel.setVisible(true); 
}

private JPanel OKCancelButtons() {

  submitButton = new JButton("Send");
  etc... etc..
  JPanel p = new JPanel();
  p.setLayout(new BoxLayout(p, BoxLayout.LINE_AXIS));
  p.add(submitButton);
  return p;
}

private JPanel createTableArea() {
  JPanel p = new JPanel();
  similar to above but a Table;
  return p;
}

You can see how I was creating the Panels in the methods than adding them to the base panel as components.

How would you do that using TitleAreaDialog?

  • 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-10T08:27:58+00:00Added an answer on June 10, 2026 at 8:27 am

    I haven’t used TitleAreaDialog yet, but here is a simple Dialog I use myself. It should give you an idea about the inner workings of a dialog. It’s basically just a dialog with some error message and a checkbox:

    public class CheckboxDialog extends Dialog {
    
        private String message = "";
        private String checkboxMessage = "";
        private boolean checkValue;
    
        private Button checkButton;
    
        /* Constructor, set shell style and set block on open (rest of gui is blocked until closed) */
        public CheckboxDialog(Shell parentShell) {
            super(parentShell);
            setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.OK | SWT.APPLICATION_MODAL);
            setBlockOnOpen(true);
        }
    
        /* creates the content of the dialog */
        protected Control createDialogArea(Composite parent) {
            Composite composite = (Composite) super.createDialogArea(parent);
    
            /* set the layout for the content (gridlayout with 1 column)*/
            GridLayout layout = new GridLayout(1, false);
            layout.marginHeight = 15;
            layout.marginWidth = 30;
            composite.setLayout(layout);
    
            /* add a label with some text */
            final Label content = new Label(composite, SWT.NONE);
            content.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            content.setText(message);
    
            /* add a checkbox button */
            checkButton = new Button(composite, SWT.CHECK);
            checkButton.setText(checkboxMessage);
            checkButton.setSelection(true);
            checkButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    
            return composite;
        }
    
        /* create the dialog buttons (in this case, only an OK button) */
        protected void createButtonsForButtonBar(Composite parent)
        {
            createButton(parent, IDialogConstants.OK_ID, "OK", true);
        }
    
        /* configure the dialog's shell (set title) */
        protected void configureShell(Shell newShell) {
            super.configureShell(newShell);
            newShell.setText("Error");
        }
    
        /* this method is executed if the OK button is pressed */
        public void okPressed()
        {
            checkValue = checkButton.getSelection();
            close();
        }
    
        /* getter and setter methods */
        public void setMessage(String message) {
            this.message = message;
        }
    
        public void setCheckboxMessage(String checkboxMessage) {
            this.checkboxMessage = checkboxMessage;
        }
    
        public boolean getCheckBoxValue()
        {
            return checkValue;
        }
    }
    

    As you can see, there is no add method in SWT. You just specify the parent in the constructor of each widget.

    Moreover, here is a really good tutorial by Vogella, that explains in detail how to create a JFace dialog. Here is another example on how to use the TitleAreaDialog.

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

Sidebar

Related Questions

I'm trying to create a Quicksort base class using VB.NET, taking it an array
I am trying to create a derived class object in base class method. I
I am trying to create a class in VB.NET which inherits a base abstract
I'm trying to create a generic method to use in my base class for
C#, .net 3.5 I am trying to create a base class that has a
What I am trying to do is create a base class, for which anything
Here is the scope. I am trying to create a base class you will
I'm trying to create a base class that provides a good amount of re-usable
Trying to create a base class for my Views in my Silverlight 4 Business
I am trying to create a base class that is a wrapper around std::array

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.