Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » auto resize GridData
auto resize GridData [message #478816] Fri, 07 August 2009 06:10
caesar  is currently offline caesar Friend
Messages: 6
Registered: July 2009
Junior Member
I have StyledText set as GridData on the Composite.

I want to auto-resize while I type characters so i added KeyListener to the StyledText like this.

StyledText textControl = new StyledText(composite, SWT.WRAP | SWT.BORDER | SWT.MULTI);
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gridData.heightHint = 40;
textControl.addKeyListener(new TextKeyListener(composite, textControl, gridData));

class TextKeyListener implements KeyListener {
public void keyPressed(KeyEvent e) {
Rectangle rectangle = text.getTextBounds(0, text.getText().length()-1);
lineHeight = 0 + rectangle.height;
if (lineHeight >= initHeight) {
gridData.heightHint = gridData.heightHint + 13;
initHeight = gridData.heightHint;

Even though composite.layout() is called, gridData doesn't get bigger. The size is still same.

is there a way to resize GridData?

Previous Topic:Close editor via button?
Next Topic:Re: Capturing All Key Events in a Text Field
Goto Forum:

Current Time: Sun Jan 26 20:11:44 GMT 2020

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

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

Back to the top