'eclipse dialog area widget size
I open a dialog via button click and want that the dialog is opened in the fully horizontal size as needed by the text without scrolling.
protected Control createDialogArea(Composite parent) {
Composite comp = (Composite) super.createDialogArea(parent);
Font font = parent.getFont();
Group group = new Group(comp, SWT.NONE);
GridLayout topLayout = new GridLayout();
group.setLayout(topLayout);
GridData gd = new GridData(GridData.FILL, SWT.FILL, true, true);
gd.heightHint = convertHeightInCharsToPixels(15);
gd.widthHint = convertWidthInCharsToPixels(50);
group.setLayoutData(gd);
group.setFont(font);
fText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = convertHeightInCharsToPixels(10);
gd.widthHint = convertWidthInCharsToPixels(60);
fText .setLayoutData(gd);
fText .setText(text);
fText .setEditable(false);
return comp;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
