Wide Text control in JFace dialog [message #252649] |
Tue, 15 June 2004 05:57 |
Eclipse User |
|
|
|
Originally posted by: christian.hauser.dvbern.ch
Hello
I have a JFace dialog (extending TitleAreaDialog) and would like to have
a Text control that is as wide as the width of the dialog. I tried that
using the code below with a FormLayout. However, the Text control is
always displayed in a default width.
I'm glad for any hints on how to have a Text control within my dialog
that has the same width as the dialog.
Kind regards,
Christian
/* TestDialog.java */
/*-----------------*/
import org.eclipse.jface.dialogs.*;
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public final class TestDialog extends TitleAreaDialog {
public TestDialog(Shell parentShell) {
super(parentShell);
}
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("Test Dialog");
}
protected void setShellStyle(int newShellStyle) {
//super.setShellStyle(newShellStyle | SWT.RESIZE);
super.setShellStyle(newShellStyle);
}
protected void createButtonsForButtonBar(Composite parent) {
//super.createButtonsForButtonBar(parent);
// Create Save and Cancel buttons
createButton(parent, IDialogConstants.OK_ID, "Save", true);
createButton(parent, IDialogConstants.CANCEL_ID, "Cancel", false);
}
protected Control createDialogArea(Composite parent) {
setTitle("Test Dialog");
setMessage("A dialog to test the layout problems.");
Composite composite = new Composite((Composite)
super.createDialogArea(parent), SWT.NONE);
// Set the layout of the composite
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = 10; // Default: 0
formLayout.marginHeight = 20; // Default: 0
formLayout.spacing = 0; // Default: 0
composite.setLayout(formLayout);
Text text = new Text(composite, SWT.SINGLE | SWT.BORDER);
FormData formData = new FormData();
formData.left = new FormAttachment(0, 5);
formData.right = new FormAttachment(100, -5);
text.setLayoutData(formData);
return composite;
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02193 seconds