Skip to main content

TextRun Class

A text run in a paragraph.

Declaration

public class TextRun extends OfficeTextRunString

Remarks

A TextParagraph in a text area contains text runs. A text run is a contiguous sequence of characters within a paragraph that shares the same character formatting.

Each run is a TextRun object and defines a region of the text with its own set of characteristics. Use the TextParagraph.getRuns() method to obtain a collection of text runs.

DevExpress Presentation API - TextArea structure

The following code snippet adds a text run with custom formatting to a paragraph:

import com.devexpress.docs.presentation.*;
import com.devexpress.docs.office.*;
//...
// Create a rounded rectangle shape with specified position and size.
Shape shape = new Shape(ShapeType.getRoundedRectangle(), 50, 50, 500, 700);

// Create a paragraph with initial text content.
TextParagraph textParagraph = new TextParagraph("Hello ");

// Create text properties and enable bold formatting.
TextProperties textProperties = new TextProperties();
textProperties.setBold(true);

// Create a text run that uses the bold formatting.
TextRun textRun = new TextRun("World!");
textRun.setTextProperties(textProperties);

// Add the formatted text run to the paragraph.
textParagraph.getRuns().add(textRun);

// Add the paragraph to the shape's text area.
shape.getTextArea().getParagraphs().add(textParagraph);

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Constructors

TextRun() Constructor

Initializes a new instance of the TextRun class.

Declaration

public TextRun()

TextRun(String text, TextProperties textProperties) Constructor

Initializes a new instance of the TextRun class with specified settings.

Declaration

public TextRun(String text, TextProperties textProperties)

Parameters

Name Type Description
text String

The text content of the text run.

textProperties TextProperties

Text properties applied to the text run.

TextRun(String text) Constructor

Initializes a new instance of the TextRun class with specified settings.

Declaration

public TextRun(String text)

Parameters

Name Type Description
text String

The content of the text run.

Methods

deepClone() Method

Returns a deep copy of this TextRun instance.

Declaration

public TextRun deepClone()

Returns

Type Description
TextRun

A deep copy of this TextRun.