Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Wide Text control in JFace dialog
Wide Text control in JFace dialog [message #252649] Tue, 15 June 2004 09:57
Eclipse UserFriend
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;
}
}
Previous Topic:Problem with placeholders
Next Topic:[Navigator View] Extension
Goto Forum:
  


Current Time: Fri Sep 27 05:31:46 GMT 2024

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

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

Back to the top