TextBoxControl

Inheritance: java.lang.Object, com.aspose.words.OleControl, com.aspose.words.Forms2OleControl, com.aspose.words.MorphDataControl

public class TextBoxControl extends MorphDataControl

The TextBox control displays text from an organized set of data or user input.

Examples:

Shows how to change text of the TextBox OLE control.


 Document doc = new Document(getMyDir() + "Textbox control.docm");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 TextBoxControl textBoxControl = (TextBoxControl)shape.getOleFormat().getOleControl();
 Assert.assertEquals(textBoxControl.getText(), "Aspose.Words test");

 textBoxControl.setText("Updated text");
 Assert.assertEquals(textBoxControl.getText(), "Updated text");
 

Methods

MethodDescription
getBackColor()Gets a background color of the control.
getCaption()Gets a Caption property of the control.
getChildNodes()Gets collection of immediate child controls.
getClsidInternal()
getEnabled()Returns true if control is in enabled state.
getExtensionForUser(String progId)
getFileNameForUser()
getForeColor()Gets a foreground color of the control.
getGroupName()Gets a string that specifies a group of mutually exclusive controls.
getHeight()Gets a height of the control in points.
getId()
getName()Gets name of the ActiveX control.
getText()Gets a text of the control.
getType()Gets type of Forms 2.0 control.
getValue()Gets underlying Value property which often represents control state.
getWidth()Gets a width of the control in points.
isEmpty()
isForms2OleControl()Returns true if the control is a Forms2OleControl.
isForms2OleControlInternal()
setBackColor(Color value)Sets a background color of the control.
setCaption(String value)Sets a Caption property of the control.
setForeColor(Color value)Sets a foreground color of the control.
setGroupName(String value)Sets a string that specifies a group of mutually exclusive controls.
setHeight(double value)Sets a height of the control in points.
setId(int value)
setName(String value)Sets name of the ActiveX control.
setText(String value)Sets a text of the control.
setWidth(double value)Sets a width of the control in points.

getBackColor()

public Color getBackColor()

Gets a background color of the control. The default value depends on a type of the control.

Examples:

Shows how to set properties for ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 Forms2OleControl oleControl = (Forms2OleControl)shape.getOleFormat().getOleControl();
 oleControl.setForeColor(new Color((0x17), (0xE1), (0x35)));
 oleControl.setBackColor(new Color((0x33), (0x97), (0xF4)));
 oleControl.setHeight(100.54);
 oleControl.setWidth(201.06);
 

Returns: java.awt.Color - A background color of the control.

getCaption()

public String getCaption()

Gets a Caption property of the control. Default value is an empty string.

Examples:

Shows how to set caption for ActiveX control.


 DocumentBuilder builder = new DocumentBuilder();

 CommandButtonControl button1 = new CommandButtonControl(); { button1.setCaption("Button caption"); }
 Shape shape = builder.insertForms2OleControl(button1);
 Assert.assertEquals("Button caption", ((Forms2OleControl)shape.getOleFormat().getOleControl()).getCaption());
 

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Returns: java.lang.String - A Caption property of the control.

getChildNodes()

public Forms2OleControlCollection getChildNodes()

Gets collection of immediate child controls.

Remarks:

Returns null if this control can not have children.

Examples:

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Returns: Forms2OleControlCollection - Collection of immediate child controls.

getClsidInternal()

public String getClsidInternal()

Returns: java.lang.String

getEnabled()

public boolean getEnabled()

Returns true if control is in enabled state.

Examples:

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Returns: boolean - true if control is in enabled state.

getExtensionForUser(String progId)

public String getExtensionForUser(String progId)

Parameters:

ParameterTypeDescription
progIdjava.lang.String

Returns: java.lang.String

getFileNameForUser()

public String getFileNameForUser()

Returns: java.lang.String

getForeColor()

public Color getForeColor()

Gets a foreground color of the control. The default value depends on a type of the control.

Examples:

Shows how to set properties for ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 Forms2OleControl oleControl = (Forms2OleControl)shape.getOleFormat().getOleControl();
 oleControl.setForeColor(new Color((0x17), (0xE1), (0x35)));
 oleControl.setBackColor(new Color((0x33), (0x97), (0xF4)));
 oleControl.setHeight(100.54);
 oleControl.setWidth(201.06);
 

Returns: java.awt.Color - A foreground color of the control.

getGroupName()

public String getGroupName()

Gets a string that specifies a group of mutually exclusive controls. The default value is an empty string.

Examples:

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Returns: java.lang.String - A string that specifies a group of mutually exclusive controls.

getHeight()

public double getHeight()

Gets a height of the control in points.

Examples:

Shows how to set properties for ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 Forms2OleControl oleControl = (Forms2OleControl)shape.getOleFormat().getOleControl();
 oleControl.setForeColor(new Color((0x17), (0xE1), (0x35)));
 oleControl.setBackColor(new Color((0x33), (0x97), (0xF4)));
 oleControl.setHeight(100.54);
 oleControl.setWidth(201.06);
 

Returns: double - A height of the control in points.

getId()

public int getId()

Returns: int

getName()

public String getName()

Gets name of the ActiveX control.

Examples:

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Returns: java.lang.String - Name of the ActiveX control.

getText()

public String getText()

Gets a text of the control.

Examples:

Shows how to change text of the TextBox OLE control.


 Document doc = new Document(getMyDir() + "Textbox control.docm");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 TextBoxControl textBoxControl = (TextBoxControl)shape.getOleFormat().getOleControl();
 Assert.assertEquals(textBoxControl.getText(), "Aspose.Words test");

 textBoxControl.setText("Updated text");
 Assert.assertEquals(textBoxControl.getText(), "Updated text");
 

Returns: java.lang.String - A text of the control.

getType()

public int getType()

Gets type of Forms 2.0 control.

Examples:

Shows how to change text of the TextBox OLE control.


 Document doc = new Document(getMyDir() + "Textbox control.docm");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 TextBoxControl textBoxControl = (TextBoxControl)shape.getOleFormat().getOleControl();
 Assert.assertEquals(textBoxControl.getText(), "Aspose.Words test");

 textBoxControl.setText("Updated text");
 Assert.assertEquals(textBoxControl.getText(), "Updated text");
 

Returns: int - Type of Forms 2.0 control. The returned value is one of Forms2OleControlType constants.

getValue()

public String getValue()

Gets underlying Value property which often represents control state. For example checked option button has ‘1’ value while unchecked has ‘0’. Default value is an empty string.

Examples:

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Returns: java.lang.String - Underlying Value property which often represents control state.

getWidth()

public double getWidth()

Gets a width of the control in points.

Examples:

Shows how to set properties for ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 Forms2OleControl oleControl = (Forms2OleControl)shape.getOleFormat().getOleControl();
 oleControl.setForeColor(new Color((0x17), (0xE1), (0x35)));
 oleControl.setBackColor(new Color((0x33), (0x97), (0xF4)));
 oleControl.setHeight(100.54);
 oleControl.setWidth(201.06);
 

Returns: double - A width of the control in points.

isEmpty()

public boolean isEmpty()

Returns: boolean

isForms2OleControl()

public boolean isForms2OleControl()

Returns true if the control is a Forms2OleControl.

Examples:

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Returns: boolean - true if the control is a Forms2OleControl.

isForms2OleControlInternal()

public boolean isForms2OleControlInternal()

Returns: boolean

setBackColor(Color value)

public void setBackColor(Color value)

Sets a background color of the control. The default value depends on a type of the control.

Examples:

Shows how to set properties for ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 Forms2OleControl oleControl = (Forms2OleControl)shape.getOleFormat().getOleControl();
 oleControl.setForeColor(new Color((0x17), (0xE1), (0x35)));
 oleControl.setBackColor(new Color((0x33), (0x97), (0xF4)));
 oleControl.setHeight(100.54);
 oleControl.setWidth(201.06);
 

Parameters:

ParameterTypeDescription
valuejava.awt.ColorA background color of the control.

setCaption(String value)

public void setCaption(String value)

Sets a Caption property of the control. Default value is an empty string.

Examples:

Shows how to set caption for ActiveX control.


 DocumentBuilder builder = new DocumentBuilder();

 CommandButtonControl button1 = new CommandButtonControl(); { button1.setCaption("Button caption"); }
 Shape shape = builder.insertForms2OleControl(button1);
 Assert.assertEquals("Button caption", ((Forms2OleControl)shape.getOleFormat().getOleControl()).getCaption());
 

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Parameters:

ParameterTypeDescription
valuejava.lang.StringA Caption property of the control.

setForeColor(Color value)

public void setForeColor(Color value)

Sets a foreground color of the control. The default value depends on a type of the control.

Examples:

Shows how to set properties for ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 Forms2OleControl oleControl = (Forms2OleControl)shape.getOleFormat().getOleControl();
 oleControl.setForeColor(new Color((0x17), (0xE1), (0x35)));
 oleControl.setBackColor(new Color((0x33), (0x97), (0xF4)));
 oleControl.setHeight(100.54);
 oleControl.setWidth(201.06);
 

Parameters:

ParameterTypeDescription
valuejava.awt.ColorA foreground color of the control.

setGroupName(String value)

public void setGroupName(String value)

Sets a string that specifies a group of mutually exclusive controls. The default value is an empty string.

Examples:

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Parameters:

ParameterTypeDescription
valuejava.lang.StringA string that specifies a group of mutually exclusive controls.

setHeight(double value)

public void setHeight(double value)

Sets a height of the control in points.

Examples:

Shows how to set properties for ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 Forms2OleControl oleControl = (Forms2OleControl)shape.getOleFormat().getOleControl();
 oleControl.setForeColor(new Color((0x17), (0xE1), (0x35)));
 oleControl.setBackColor(new Color((0x33), (0x97), (0xF4)));
 oleControl.setHeight(100.54);
 oleControl.setWidth(201.06);
 

Parameters:

ParameterTypeDescription
valuedoubleA height of the control in points.

setId(int value)

public void setId(int value)

Parameters:

ParameterTypeDescription
valueint

setName(String value)

public void setName(String value)

Sets name of the ActiveX control.

Examples:

Shows how to verify the properties of an ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
 OleControl oleControl = shape.getOleFormat().getOleControl();

 Assert.assertEquals(oleControl.getName(), "CheckBox1");

 if (oleControl.isForms2OleControl()) {
     Forms2OleControl checkBox = (Forms2OleControl) oleControl;
     Assert.assertEquals(checkBox.getCaption(), "First");
     Assert.assertEquals(checkBox.getValue(), "0");
     Assert.assertEquals(checkBox.getEnabled(), true);
     Assert.assertEquals(checkBox.getType(), Forms2OleControlType.CHECK_BOX);
     Assert.assertEquals(checkBox.getChildNodes(), null);
 }
 

Parameters:

ParameterTypeDescription
valuejava.lang.StringName of the ActiveX control.

setText(String value)

public void setText(String value)

Sets a text of the control.

Examples:

Shows how to change text of the TextBox OLE control.


 Document doc = new Document(getMyDir() + "Textbox control.docm");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 TextBoxControl textBoxControl = (TextBoxControl)shape.getOleFormat().getOleControl();
 Assert.assertEquals(textBoxControl.getText(), "Aspose.Words test");

 textBoxControl.setText("Updated text");
 Assert.assertEquals(textBoxControl.getText(), "Updated text");
 

Parameters:

ParameterTypeDescription
valuejava.lang.StringA text of the control.

setWidth(double value)

public void setWidth(double value)

Sets a width of the control in points.

Examples:

Shows how to set properties for ActiveX control.


 Document doc = new Document(getMyDir() + "ActiveX controls.docx");

 Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
 Forms2OleControl oleControl = (Forms2OleControl)shape.getOleFormat().getOleControl();
 oleControl.setForeColor(new Color((0x17), (0xE1), (0x35)));
 oleControl.setBackColor(new Color((0x33), (0x97), (0xF4)));
 oleControl.setHeight(100.54);
 oleControl.setWidth(201.06);
 

Parameters:

ParameterTypeDescription
valuedoubleA width of the control in points.