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?
TextField's height can be changed in 3 ways that are based on your requirement. You can use the Font Size and Content Padding to increase the height and allow a single-line text or use the MaxLines-MinLines property to increase the overall height of the TextField as new text is entered.
Change the field size of a text fieldIn the table design grid, select the field for which you want to change the field size. In the Field Properties pane, on the General tab, enter the new field size in the Field Size property. You can enter a value from 1 to 255.
Change the font size to increase TextField's height. In TextField there is a property style:TextStyle(); Inside the textstyle there is a property called font size. Then give the appropriate font size.
size. The size attribute is a numeric value indicating how many characters wide the input field should be. The value must be a number greater than zero, and the default value is 20.
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.
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)
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With