0

I have CtabItem inside which, there is a Composite widget. Then, I have added a few components inside it. The code goes like this -

Composite composite = new Composite(tabFolder, SWT.H_SCROLL);

    tabItem.setControl(composite);


    Label lblName = new Label(composite, SWT.NONE);
    lblName.setBounds(10, 28, 55, 15);
    lblName.setText("Name");

    textName = new StyledText(composite, SWT.BORDER);
    String myText = tree.getSelection()[0].getText();
    textName.setText(myText);
    Point textNamesize = textName.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    textName.setBounds(76, 28, textNamesize.x, 21);

    Label lblPath = new Label(composite, SWT.NONE);
    lblPath.setBounds(10, 83, 55, 15);
    lblPath.setText("Path");

    textPath = new StyledText(composite, SWT.READ_ONLY);
    textPath.setBackground(new Color(d, 240, 240, 240));


    Button saveButton = new Button(composite, SWT.NONE);
    saveButton.setBounds(456, 134, 75, 25);
    saveButton.setText("Save");


    Button cancelButton = new Button(composite, SWT.NONE);
    cancelButton.setBounds(548, 134, 75, 25);
    cancelButton.setText("Cancel");

But, when I am displaying the tab, the scrolls are present, but, when I am scrolling the composite, the scroll bar moves , but the elements on the other side of the scroll are not showing Any, idea why it is not working ?

Thanks!

Srijani Ghosh
  • 3,935
  • 7
  • 37
  • 68
  • There is no `ScrolledComposite` in your code – greg-449 Sep 30 '15 at 09:36
  • Thanks @greg-449. Actually I typed in wrong. I used ScrollComposite first, then I edited the code and used Composite . Bu,t both didn't work. Now I have edited the question. Thanks – Srijani Ghosh Sep 30 '15 at 09:39
  • Can you please check this [question][1]? [1]: http://stackoverflow.com/questions/20204367/how-to-dynamically-add-swt-widgets-to-a-composite – Ardeshana Milan Sep 30 '15 at 09:53

1 Answers1

1

from GGrec's answer I created snippet for you. I have used ScrolledComposite with GridLayout. Hope it will make your task easier.

 final ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
            scrolledComposite.setExpandHorizontal(true);
            scrolledComposite.setExpandVertical(true);

            final Composite composite_parent = new Composite(scrolledComposite, SWT.NONE);
            composite_parent.setLayout(new GridLayout(3, false));
            scrolledComposite.setContent(composite_parent);
            scrolledComposite.setSize(composite_parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));

            final Composite composite_child = new Composite(composite_parent, SWT.NONE);
            composite_child.setLayout(new GridLayout(2, false));

            final Label lblDefault1 = new Label(composite_child, SWT.NONE);
            lblDefault1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
            lblDefault1.setText("Name");

            final StyledText textStyled = new StyledText(composite_child, SWT.NONE);
            textStyled.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));

            Label lblNewLabel_1 = new Label(composite_child, SWT.NONE);
            lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
            lblNewLabel_1.setText("Path");

            text = new Text(composite_child, SWT.BORDER);
            text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

            scrolledComposite.setMinSize(composite_parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Community
  • 1
  • 1
Ardeshana Milan
  • 373
  • 5
  • 23