Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Group + Scrollbar
Group + Scrollbar [message #132227] Mon, 11 May 2009 13:28 Go to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
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 15:15 Go to previous message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
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
>
Previous Topic:Workspace & EFS
Next Topic:Toolbar question
Goto Forum:
  


Current Time: Wed Apr 24 20:34:12 GMT 2024

Powered by FUDForum. Page generated in 0.02640 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top