| Home » Eclipse Projects » Remote Application Platform (RAP) » Group + Scrollbar
 Goto Forum:| 
| Group + Scrollbar [message #132227] | Mon, 11 May 2009 09:28  |  | 
| Eclipse User  |  |  |  |  | Hello, 
 I have problems with scrollbars in a group. I have a dialog window with a
 group. In this group are some controls. If I push a button, the group gets
 a new line with the same controls. It works well until the size of my
 dialog window is to small for the number of lines in the group. How can I
 get a scrollbar?
 I have the following code.
 
 
 protected Control createDialogArea(Composite parent) {
 Composite topComposite = (Composite)
 super.createDialogArea(parent);
 
 GridLayout layout = new GridLayout(3, false);
 layout.marginLeft = 5;
 layout.marginTop = 10;
 layout.horizontalSpacing = 5;
 layout.makeColumnsEqualWidth = false;
 topComposite.setLayout(layout);
 
 GridData gd = new GridData();
 
 Button andButton = new Button(topComposite, SWT.RADIO);
 andButton.setText("It all conditions must be fulfilled");
 
 Button orButton = new Button(topComposite, SWT.RADIO);
 orButton.setText("There must be at least one of the conditions are
 met.");
 orButton.setSelection(true);
 
 Composite right = new Composite(topComposite, SWT.NONE);
 layout = new GridLayout();
 layout.numColumns = 1;
 layout.marginWidth = 10;
 right.setLayout(layout);
 
 gd.horizontalSpan = 1;
 gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
 btnAdd = new Button(right, SWT.NONE);
 btnAdd.setText("+");
 
 btnAdd.addMouseListener(new MouseListener() {
 public void mouseUp(MouseEvent arg0) {
 addValueDisplayNameGuiElement("");
 }
 
 public void mouseDoubleClick(MouseEvent arg0) {
 }
 
 public void mouseDown(MouseEvent arg0) {
 }
 });
 
 gd = new GridData();
 gd.horizontalSpan = 3;
 gd.horizontalAlignment = GridData.FILL;
 gd.verticalAlignment = GridData.FILL;
 gd.grabExcessHorizontalSpace = true;
 gd.grabExcessVerticalSpace = true;
 Group grpValues = new Group(topComposite, SWT.H_SCROLL);
 grpValues.setText("Values");
 grpValues.setLayoutData(gd);
 GridLayout grpLayout = new GridLayout(1, false);
 grpValues.setLayout(grpLayout);
 
 pnlValues = new Composite(grpValues, SWT.H_SCROLL);
 GridLayout pnlValuesLayout = new GridLayout(4, false);
 pnlValuesLayout.marginTop = 5;
 pnlValues.setLayout(pnlValuesLayout);
 gd = new GridData();
 gd.horizontalAlignment = GridData.FILL;
 gd.verticalAlignment = GridData.FILL;
 gd.grabExcessHorizontalSpace = true;
 gd.grabExcessVerticalSpace = true;
 pnlValues.setLayoutData(gd);
 
 addValueDisplayNameGuiElement("");
 
 applyDialogFont(topComposite);
 
 return topComposite;
 }
 
 
 protected void addValueDisplayNameGuiElement(String text) {
 Combo combo = new Combo(this.pnlValues, SWT.READ_ONLY);
 combo.setItems(ITEMS);
 combo.select(0);
 
 Combo whereCombo = new Combo(this.pnlValues, SWT.READ_ONLY);
 String[] whereItems = new String[] {"contains", "doesn't contain"};
 whereCombo.setItems(whereItems);
 whereCombo.select(0);
 
 Text textNew = new Text(this.pnlValues, SWT.NONE);
 textNew.setLayoutData(new GridData(230, 20));
 textNew.setEditable(true);
 
 Button minusButton = new Button(this.pnlValues, SWT.PUSH);
 minusButton.setText("-");
 minusButton.setLayoutData(new GridData(20,20));
 
 minusButton.addMouseListener(new RemoveValueListener(combo,
 whereCombo,textNew,minusButton));
 
 this.pnlValues.layout();
 allValueFields.add(combo);
 }
 
 
 Thanks,
 kristin
 |  |  |  |  | 
| Re: Group + Scrollbar [message #132265 is a reply to message #132227] | Mon, 11 May 2009 11:15  |  | 
| Eclipse User  |  |  |  |  | Kristin, 
 you probably need a ScrolledComposite. The ScrolledComposite is a
 complicated thing and it's easily screwed up. Thus, besides the
 JavaDoc, you should also have a look at the SWT snippets [1] for
 examples.
 
 HTH
 Rüdiger
 
 [1] http://www.eclipse.org/swt/snippets/
 
 Kristin Polenz wrote:
 > Hello,
 >
 > I have problems with scrollbars in a group. I have a dialog window with
 > a group. In this group are some controls. If I push a button, the group
 > gets a new line with the same controls. It works well until the size of
 > my dialog window is to small for the number of lines in the group. How
 > can I get a scrollbar? I have the following code.
 >
 >
 > protected Control createDialogArea(Composite parent) {
 >        Composite topComposite = (Composite) super.createDialogArea(parent);
 >
 >        GridLayout layout = new GridLayout(3, false);
 >        layout.marginLeft = 5;
 >        layout.marginTop = 10;
 >        layout.horizontalSpacing = 5;
 >        layout.makeColumnsEqualWidth = false;
 >        topComposite.setLayout(layout);
 >        GridData gd = new GridData();
 >
 >        Button andButton = new Button(topComposite, SWT.RADIO);
 >        andButton.setText("It all conditions must be fulfilled");
 >
 >        Button orButton = new Button(topComposite, SWT.RADIO);
 >        orButton.setText("There must be at least one of the conditions
 > are                      met.");
 >        orButton.setSelection(true);
 >
 >        Composite right = new Composite(topComposite, SWT.NONE);
 >        layout = new GridLayout();
 >        layout.numColumns = 1;
 >        layout.marginWidth = 10;
 >        right.setLayout(layout);
 >
 >        gd.horizontalSpan = 1;
 >        gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
 >        btnAdd = new Button(right, SWT.NONE);
 >        btnAdd.setText("+");
 >
 >        btnAdd.addMouseListener(new MouseListener() {
 >            public void mouseUp(MouseEvent arg0) {
 >                addValueDisplayNameGuiElement("");
 >            }
 >
 >            public void mouseDoubleClick(MouseEvent arg0) {
 >            }
 >
 >            public void mouseDown(MouseEvent arg0) {
 >            }
 >        });
 >
 >        gd = new GridData();
 >        gd.horizontalSpan = 3;
 >        gd.horizontalAlignment = GridData.FILL;
 >        gd.verticalAlignment = GridData.FILL;
 >        gd.grabExcessHorizontalSpace = true;
 >        gd.grabExcessVerticalSpace = true;
 >        Group grpValues = new Group(topComposite, SWT.H_SCROLL);
 >        grpValues.setText("Values");
 >        grpValues.setLayoutData(gd);
 >        GridLayout grpLayout = new GridLayout(1, false);
 >        grpValues.setLayout(grpLayout);
 >
 >        pnlValues = new Composite(grpValues, SWT.H_SCROLL);
 >        GridLayout pnlValuesLayout = new GridLayout(4, false);
 >        pnlValuesLayout.marginTop = 5;
 >        pnlValues.setLayout(pnlValuesLayout);
 >        gd = new GridData();
 >        gd.horizontalAlignment = GridData.FILL;
 >        gd.verticalAlignment = GridData.FILL;
 >        gd.grabExcessHorizontalSpace = true;
 >        gd.grabExcessVerticalSpace = true;
 >        pnlValues.setLayoutData(gd);
 >
 >        addValueDisplayNameGuiElement("");
 >
 >        applyDialogFont(topComposite);
 >
 >        return topComposite;
 >    }
 >
 >
 >    protected void addValueDisplayNameGuiElement(String text) {
 >        Combo combo = new Combo(this.pnlValues, SWT.READ_ONLY);
 >        combo.setItems(ITEMS);
 >        combo.select(0);
 >
 >        Combo whereCombo = new Combo(this.pnlValues, SWT.READ_ONLY);
 >        String[] whereItems = new String[] {"contains", "doesn't contain"};
 >        whereCombo.setItems(whereItems);
 >        whereCombo.select(0);
 >               Text textNew = new Text(this.pnlValues, SWT.NONE);
 >        textNew.setLayoutData(new GridData(230, 20));
 >        textNew.setEditable(true);
 >
 >        Button minusButton = new Button(this.pnlValues, SWT.PUSH);
 >        minusButton.setText("-");
 >        minusButton.setLayoutData(new GridData(20,20));
 >               minusButton.addMouseListener(new
 > RemoveValueListener(combo, whereCombo,textNew,minusButton));
 >
 >        this.pnlValues.layout();
 >        allValueFields.add(combo);
 >    }
 >
 >
 > Thanks,
 > kristin
 >
 |  |  |  | 
 
 
 Current Time: Fri Oct 31 01:47:38 EDT 2025 
 Powered by FUDForum . Page generated in 0.03195 seconds |