Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Scrolledcomposite eating up more than half of the inner composite.
Scrolledcomposite eating up more than half of the inner composite. [message #771923] Wed, 28 December 2011 14:43 Go to next message
Ashutosh Verma is currently offline Ashutosh VermaFriend
Messages: 3
Registered: December 2011
Junior Member
I know this problem have been mentioned and solved before in this forum but nothing working out for me.

I am using a ScrolledComposite in a JFace Dialog. I need to create a Template selection dialog box which displays Images and number of images will be read from a file.

The problem I am facing is that ScrolledComposite is eating up all the more than half of the inner composite. Scrolled Composite is not able to read the complete content and hence not scrolling the complete content. I have tried adding ReSize listener but no use. After adding listener, I need to resize the dialog to see fulll content and after it, it scroll complete content.

Link to Dialog BluePrint: index.php/fa/6588/0/

Code I have written is:
public void createChildSection (Composite parent, Component element)
List<Component> childTemplates = element.getChildren();

createLabelText(parent, element);

Composite child = new Composite (parent, 0);
GridLayout childLayout = new GridLayout(5, true);
childLayout.marginBottom = 5;
childLayout.marginTop = 5;
childLayout.marginLeft = 10;
childLayout.marginRight = 10;
childLayout.makeColumnsEqualWidth = true;
childLayout.horizontalSpacing = 20;
childLayout.verticalSpacing = 15;
child.setBackground(new Color(getShell().getDisplay(), 255, 255, 255));

for (int i=0; i<childTemplates.size(); ++i)
Component template = childTemplates.get(i);
createImage(child, template);

public void createDialogSection(Composite parent, ArrayList<Component> templates)
List<Component> totalTemplateType = templates.get(0).getChildren();

parent.setLayout(new GridLayout());
parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
parent.setBackground(new Color(getShell().getDisplay(), 255, 255, 255));

for ( int i=0; i<totalTemplateType.size(); ++i )
Component childTemplate = totalTemplateType.get(i);
createChildSection(parent, childTemplate);

protected Control createDialogArea(Composite parent) {

Composite composite = new Composite(parent, 0);
getShell().setText("Select Template");

GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
composite.setLayoutData(new GridData(GridData.FILL_BOTH));

// Creating Scrollable composite
final ScrolledComposite scrolledComposite = new ScrolledComposite(composite, SWT.V_SCROLL | SWT.BORDER);

final Composite parentSection = new Composite(scrolledComposite, 0);

parentSection.addListener(SWT.Resize, new Listener() {
int width = -1;
public void handleEvent(Event e) {
int newWidth = parentSection.getSize().y;
if (newWidth != width) {
scrolledComposite.setMinHeight(parentSection.computeSize(IMAGE_SECTION_WIDTH, newWidth).y);
width = newWidth;

scrolledComposite.setLayout(new GridLayout());
scrolledComposite.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true));

createDialogSection(parentSection, (ArrayList<Component>) getTableInput());

return composite;
Re: Scrolledcomposite eating up more than half of the inner composite. [message #775485 is a reply to message #771923] Fri, 06 January 2012 04:47 Go to previous message
Ashutosh Verma is currently offline Ashutosh VermaFriend
Messages: 3
Registered: December 2011
Junior Member
Got it resolved.
parentSection.setSize(parentSection.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Put this line after call to createDialogSection method.

Thanks guys for looking into my problem.
Previous Topic:Setting dialog title
Next Topic:Get list of Recently Opened File & display it in a dialog
Goto Forum:

Current Time: Fri Nov 27 19:03:26 GMT 2020

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

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

Back to the top