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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:13:00+00:00 2026-05-15T17:13:00+00:00

I’ve been banging away at this for a while now and I can’t seem

  • 0

I’ve been banging away at this for a while now and I can’t seem to get anywhere. I’ve tried all of the examples I can find online and nothing seems to work! I haven’t been able to find much on this problem which leads me to think I’m missing something basic. . .

In my Eclipse RCP program I want to display a dialog that will show a list of errors that occurred while loading a data file. I have overridden TitleAreaDialog and simply want to display a scrollable Text containing the list of errors and an OK button.

The problem is that the Text vertical scroll bars don’t become active – the Text just grows taller to fit the text. This makes the dialog window height increases until it either fits the Text box or until it reaches the height of the screen – and then it just cuts off the bottom of the Text box.

How do I prevent the Dialog/Text box from growing too large? What am I missing?

Thanks for your help!!
-Christine

…

Here is a simple program showing my Dialog:

import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.*;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;


public class ScrollableDialogRunner {

    public static void main(String[] args) {
        System.out.println("starting");
        Display display = new Display ();
        Shell shell = new Shell (display);

        String errors = "one\ntwo\nthree\nfour\nfive\n";
        for(int i = 0; i < 5; i++){
            errors += errors;
        }

        ScrollableDialog dialog = new ScrollableDialog(shell, "Errors occurred during load", "The following errors occurred while loaded file 'x.data'", errors);
        dialog.open();
    }
}


class ScrollableDialog extends TitleAreaDialog {
    private String title;
    private String text;
    private String scrollableText;

    public ScrollableDialog(Shell parentShell, String title, String text, String scrollableText) {
        super(parentShell);
        this.title = title;
        this.text = text;
        this.scrollableText = scrollableText;
    }

    @Override
    protected Control createDialogArea(Composite parent) {
        GridLayout layout = new GridLayout();
        layout.numColumns = 1;
        parent.setLayout(layout);

        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalAlignment = GridData.FILL;

        Text scrollable = new Text(parent, SWT.BORDER | SWT.V_SCROLL);
        scrollable.setLayoutData(gridData);
        scrollable.setText(scrollableText);

        return parent;
    }

    @Override
    public void create() {
        super.create();

        setTitle(title);
        setMessage(text, IMessageProvider.ERROR);
    }

    @Override
    protected void createButtonsForButtonBar(Composite parent) {
        Button okButton = createButton(parent, OK, "OK", true);
        okButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                close();
            }
        });
    }

    @Override
    protected boolean isResizable() {
        return false;
    }
}
  • 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-05-15T17:13:00+00:00Added an answer on May 15, 2026 at 5:13 pm

    Assign a size to the dialog; otherwise, the dialog will layout the children asking them for their “preferred” size (which is infinite for the text widget) and will resize itself accordingly.

    [EDIT] This version works. See my comments for details.

    class ScrollableDialog extends TitleAreaDialog {
        private String title;
        private String text;
        private String scrollableText;
    
        public ScrollableDialog(Shell parentShell, String title, String text, String scrollableText) {
            super(parentShell);
            this.title = title;
            this.text = text;
            this.scrollableText = scrollableText;
        }
    
        @Override
        protected Control createDialogArea(Composite parent) {
            Composite composite = (Composite) super.createDialogArea (parent); // Let the dialog create the parent composite
    
            GridData gridData = new GridData();
            gridData.grabExcessHorizontalSpace = true;
            gridData.horizontalAlignment = GridData.FILL;
            gridData.grabExcessVerticalSpace = true; // Layout vertically, too! 
            gridData.verticalAlignment = GridData.FILL;
    
            Text scrollable = new Text(composite, SWT.BORDER | SWT.V_SCROLL);
            scrollable.setLayoutData(gridData);
            scrollable.setText(scrollableText);
    
            return composite;
        }
    
        @Override
        public void create() {
            super.create();
    
            // This is not necessary; the dialog will become bigger as the text grows but at the same time,
            // the user will be able to see all (or at least more) of the error message at once
            //getShell ().setSize (300, 300);
            setTitle(title);
            setMessage(text, IMessageProvider.ERROR);
    
        }
    
        @Override
        protected void createButtonsForButtonBar(Composite parent) {
            Button okButton = createButton(parent, OK, "OK", true);
            okButton.addSelectionListener(new SelectionAdapter() {
    
                @Override
                public void widgetSelected(SelectionEvent e) {
                    close();
                }
            });
        }
    
        @Override
        protected boolean isResizable() {
            return true; // Allow the user to change the dialog size!
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.