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
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.setLayoutData(gridData);
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;
}
text.layout();
_composite.layout();
}
}

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

is there a way to resize GridData?

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


Current Time: Tue Sep 23 10:31:47 GMT 2014

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

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