Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Controls getting too much space with TableWrapLayout in WizardPage
Controls getting too much space with TableWrapLayout in WizardPage [message #453443] Tue, 05 April 2005 18:36
Chris Merrill is currently offline Chris MerrillFriend
Messages: 19
Registered: July 2009
Junior Member
I'm new to SWT/JFace, but been doing GUIs in awt/swing/mfc for years.
I'm getting some behavior that seems strange to me, I can't figure
out if I'm doing something wrong or if something is broken.

I'd attach screenshots...but I doubt they would make it through.
Basically, adding one text field totally changes the vertical
space consumed by the container. The supringing part is that
the container actually gets SMALLER!

If you run the attached example, it will create a minimal shell
and show a wizard on it. Look at all that blank space! I don't
know why so much blank space is rendered in the WizardPage.
Next, cancel the wizard and another comes up - it is almost
identical except I added one more text field. You'll see that the
wizard gets smaller!

Note that there is a 2-column layout. This example is trimmed down
from what we are actually trying to build - but this behavior has got
us scratching our heads.

Any ideas?
What am I missing?


TIA,
Chris




--------------------------------- begin source ---------------------------------
package test;

import org.eclipse.jface.wizard.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
import org.eclipse.ui.forms.widgets.*;

/**
*/
public class MyWizardPage extends WizardPage
{
public MyWizardPage(boolean create_text_field)
{
super("intro");
setTitle("title");
setDescription("description");
_create_text_field = create_text_field;
}

public void createControl(Composite parent)
{
toolkit = new FormToolkit(parent.getDisplay());
// toolkit.setBackground(parent.getBackground());
form = toolkit.createForm(parent);
form.setText("prompt");
setControl(form);

Composite body = form.getBody();
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 2;
layout.verticalSpacing = 10;
layout.topMargin = 10;
layout.bottomMargin = 10;
layout.leftMargin = 10;
layout.rightMargin = 10;
body.setLayout(layout);

Label label1 = toolkit.createLabel(body, "Here is a medium length line. It is not particularly long.", SWT.WRAP);
label1.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.CENTER, 1, 2));
Label label2 = toolkit.createLabel(body, "Here is a long line. It is pretty long. Well, long enough to wrap
in the wizard, anyway. It goes on and on an on for no particular purpose, really. It just keeps going. Kinda like
that bunny in those battery commercials.", SWT.WRAP);
label2.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.CENTER, 1, 2));

Label labelA = toolkit.createLabel(body, "field A", SWT.NONE);
labelA.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.CENTER, 1, 1));
Label labelB = toolkit.createLabel(body, "field B", SWT.NONE);
labelB.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.CENTER, 1, 1));

if (_create_text_field)
{
Text _url_field = toolkit.createText(body, "default value for field #1", SWT.BORDER);
_url_field.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
}

}

public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("testing...");
shell.pack();
shell.open();


createWizard(shell, false);
createWizard(shell, true);

}

private static void createWizard(Shell shell, boolean create_text_field)
{
Wizard wizard = new Wizard()
{
public boolean performFinish()
{
return true; //To change body of implemented methods use File | Settings | File Templates.
}
};
wizard.addPage(new MyWizardPage(create_text_field));

WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.open();
}

public void dispose()
{
super.dispose();
toolkit.dispose();
}

private FormToolkit toolkit;
private Form form;
boolean _create_text_field;
}
---------------------------------- end source ----------------------------------


--
************************************
Chris Merrill
st.ng4@christophermerrillZZZ.net
(remove the ZZZ to contact me)
************************************
Previous Topic:Is there a way to get the version from SWT
Next Topic:Trouble with put WS_EX_LAYERED (0x80000) flag on the Canvas window
Goto Forum:
  


Current Time: Sun Oct 20 16:56:52 GMT 2019

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

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

Back to the top