Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Problem with ScrolledForm
Problem with ScrolledForm [message #115312] Thu, 11 December 2008 11:37 Go to next message
Terry  is currently offline Terry Friend
Messages: 19
Registered: July 2009
Junior Member
Hi all,

I want to make the scroll bars visible only when some contents in the
composite are not shown.
But the following code cannot achieve my purpose, what shall I do?

import org.eclipse.rwt.graphics.Graphics;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.part.ViewPart;

public class FormTest extends ViewPart{

public static final String ID = "net.HomePageView";
private Composite formComposite;

@Override
public void createPartControl(Composite parent) {
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
ScrolledForm form = toolkit.createScrolledForm(parent);


/*
If following line is added, scroll bars always show.
If not added, scroll bars will not show even after I click "test" button
many times.
*/
//form.setAlwaysShowScrollBars(true);

formComposite = form.getBody();
formComposite.setLayout(new GridLayout());
formComposite.setBackground(Graphics.getColor(255,255,230));

Button btn = new Button(formComposite, SWT.NONE);
btn.setText("test");
btn.addSelectionListener(new SelectionAdapter(){

@Override
public void widgetSelected(SelectionEvent e) {

for(int i=0;i<5;i++){
Label label = new Label(formComposite , SWT.NONE);
label.setText("test label");
Composite formcomposite = label.getParent();
formcomposite.layout();

/* The scroll bars will display when add the following code,
but the size of form will be changed.
*/
//Composite form2 = formcomposite.getParent();
//form2.pack();
}

}});
}

@Override
public void setFocus() {}
}

Cheers,
Terry
Re: Problem with ScrolledForm [message #115733 is a reply to message #115312] Mon, 15 December 2008 11:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ifurnadjiev.innoopract.com

Hi Terry,

please change your code as follow (add form.reflow( true )):
-----------
Label label = new Label(formComposite , SWT.NONE);
label.setText("test label");
Composite formcomposite = label.getParent();
formcomposite.layout();
form.reflow( true );
-----------
You should make the form final. Hope that this will help.

Best,
Ivan
Re: Problem with ScrolledForm [message #116151 is a reply to message #115733] Thu, 18 December 2008 04:27 Go to previous message
Terry  is currently offline Terry Friend
Messages: 19
Registered: July 2009
Junior Member
Hi Ivan,

Thank you for your reply. I try as you suggest and it does take effect. But
I still have a question.

By using form.reflow( true ), the scrolling is not fluent; but by
form.setAlwaysShowScrollBars(true), the scrolling is fluent.

Thanks,
Terry

Ivan Furnadjiev wrote:

> Hi Terry,
>
> please change your code as follow (add form.reflow( true )):
> -----------
> Label label = new Label(formComposite , SWT.NONE);
> label.setText("test label");
> Composite formcomposite = label.getParent();
> formcomposite.layout();
> form.reflow( true );
> -----------
> You should make the form final. Hope that this will help.
>
> Best,
> Ivan
Previous Topic:Tooling source code?
Next Topic:RAP Session
Goto Forum:
  


Current Time: Wed Feb 08 11:37:22 GMT 2023

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

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

Back to the top