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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:31:10+00:00 2026-06-04T11:31:10+00:00

This is a question about which general approach to take, so I haven’t included

  • 0

This is a question about which general approach to take, so I haven’t included any code.

Requirement:
I need to create a page within a multi-page editor that has two vertical sections in it. The top section has a tree and the bottom section has a text field. The tree and text field should fill their respective sections. Each section should scroll independently and there should be a splitter in between. When the editor is opened I want the visible area of the editor to be divided among the two sections based on some ratio I provide. Then when the editor is resized, the two sections will adjust proportionally to maintain the ratio and fit the page. This way there won’t be scroll bars on the editor page itself, just the two sections.

Proposed Solution:
My idea was to add a SashForm to the editor page and set the size of the SashForm to be the same as the editor’s visible area. Then I’d add a resize listener to the editor page and adjust the size of the SashForm so that it stays in sync with the page. However, I can’t find a way to get the editor’s visible area. So when I add the SashForm it just makes each section big enough to fit its data and adds a scroll on the editor page itself.

Is it possible to meet my requirement?

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

    Success! The key was to listen for resize events on the ScrolledForm. I’ve only tested on Fedora but I’ll take a look on Windows soon. The only thing that bothers me is that the use of the buffer constants seems a little hacky.

    /**
     * Form page that contains a sash form and a button.  The sash form is dynamically sized to ensure
     * that it always fills the available space on the page.
     */
    public class SashFormDemoPage extends FormPage
    {
        /** Horizontal buffer needed to ensure that content fits inside the page */
        private static final int HORIZONTAL_BUFFER = 8;
        /** Vertical buffer needed to ensure that content fits inside the page */
        private static final int VERTICAL_BUFFER = 12;
    
        /** Percentages of the sash form occupied by the tree and text box respectively */
        private static final int[] SASH_FORM_WEIGHTS = new int[] {30, 70};
    
    
        /**
         * Constructor
         * 
         * @param editor    parent editor
         */
        public SashFormDemoPage(ComponentEditor editor)
        {
            super(editor, "sashFormDemoPage", "Demo");
        }
    
    
        /**
         * {@inheritDoc}
         */
        @Override
        protected void createFormContent(IManagedForm managedForm)
        {
            // Set page title
            ScrolledForm scrolledForm = managedForm.getForm();
            scrolledForm.setText("SashForm Demo");
    
            // Set page layout and add a sash form
            final Composite parent = scrolledForm.getBody();
            parent.setLayout(new GridLayout());
            final SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
    
            // Add a tree as the top row of the sash form and fill it with content
            FormToolkit toolkit = managedForm.getToolkit();
            int style = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
            Tree tree = toolkit.createTree(sashForm, style);
    
            for (int i = 0; i < 40; i++) {
                TreeItem parentNode = new TreeItem(tree, SWT.NONE);
                parentNode.setText("parent-" + i);
                for (int j = 0; j < 3; j++) {
                    TreeItem childNode = new TreeItem(parentNode, SWT.NONE);
                    childNode.setText("child-" + i + "-" + j);
                }
            }
    
            // Add a text box as the bottom row of the sash form and fill it with content
            style = SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER;
            Text text = toolkit.createText(sashForm, null, style);
    
            String message = "";
            for (int i = 0; i < 100; i++) {
                message += "This is a test of the layout demo system.  This is only a test.  ";
            }
            text.setText(message);
    
            // Add button below sash form
            final Button button = toolkit.createButton(parent, "Test", SWT.NONE);
    
            // Add resize listener to sash form's parent so that sash form always fills the page
            parent.addControlListener(new ControlListener() {
                @Override
                public void controlMoved(ControlEvent e)
                {
                    // Stub needed to implement ControlListener
                }
    
                @Override
                public void controlResized(ControlEvent e)
                {
                    GridData data = new GridData();
                    Point size = parent.getSize();
                    data.widthHint = size.x - HORIZONTAL_BUFFER;
                    data.heightHint = size.y - button.getSize().y - VERTICAL_BUFFER;
                    sashForm.setLayoutData(data);
                }
            });
    
            // Set sash form's weights and pack its parent so that the initial layout is correct
            sashForm.setWeights(SASH_FORM_WEIGHTS);
            parent.pack();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I just have posted a question about this code (which was answered): $(document).ready(Main);
This question is not about which is the best, it is about which makes
This question is about the threshold at which Math.Floor(double) and Math.Ceiling(double) decide to give
[EDIT: this question is about Mozilla Audio Data API which is no longer considered
This is similar to this question, which is about a bash file . We've
This is a general design question about how to make a web application that
Ok this is more of general technology/approach question. We have a very simple web
I've been asked this question about distributed source control in general by someone who's
This question is about a general technique in SQL, that I can't quite work
This question is about acts_as_taggable_on but I believe it applies to tagging in general.

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.