问题
I am using org.eclipse.swt.widgets.Text
's type of Text field. I want to increase the length of the field. How would I do this?
回答1:
For each field, if your general layout manager is GridLayout, your textbox layout data will be GridData. Pass width and height into the GridData constructor and set it to the textbox (textbox.setLayoutData()), along with the properties about how you want the layout manager to manipulate the field.
回答2:
Since Text is a control, it inherits the method: Text.setSize(width, height)
. This lets you set the actual dimensions of the Text field. Change the width to be something larger. You might also want to keep the height the same by doing something like
textField.setSize(width, textField.getSize().y)
回答3:
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Text.html
Text inherits these methods from Control:
public void setSize(int width,int height)
public void setSize(Point size)
来源:https://stackoverflow.com/questions/2320292/increasing-the-size-of-the-text-field