Uses of Class javax.swing.text.Segment (Java Platform SE 8 )
Date: 2026-04-22

## Uses of Class
javax.swing.text.Segment

- Packages that use Segment
  Package | Description
  --- | ---
  javax.swing.text | Provides classes and interfaces that deal with editable and noneditable text components.

- - ### Uses of Segment in javax.swing.text

    Methods in javax.swing.text that return Segment
    Modifier and Type | Method and Description
    --- | ---
    `protected Segment` | WrappedPlainView.`getLineBuffer()` Gives access to a buffer that can be used to fetch text from the associated document.
    `protected Segment` | PlainView.`getLineBuffer()` Gives access to a buffer that can be used to fetch text from the associated document.
    `Segment` | GlyphView.`getText(int p0, int p1)` Fetch a reference to the text that occupies the given range.

    Methods in javax.swing.text with parameters of type Segment
    Modifier and Type | Method and Description
    --- | ---
    `static int` | Utilities.`drawTabbedText(Segment s, int x, int y, Graphics g, TabExpander e, int startOffset)` Draws the given text, expanding any tabs that are contained using the given tab expansion technique.
    `static int` | Utilities.`getBreakLocation(Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset)` Determine where to break the given text to fit within the given span.
    `void` | StringContent.`getChars(int where, int len, Segment chars)` Retrieves a portion of the content.
    `void` | GapContent.`getChars(int where, int len, Segment chars)` Retrieves a portion of the content.
    `void` | AbstractDocument.Content.`getChars(int where, int len, Segment txt)` Gets a sequence of characters and copies them into a Segment.
    `static int` | Utilities.`getTabbedTextOffset(Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset)` Determines the relative offset into the given text that best represents the given span in the view coordinate system.
    `static int` | Utilities.`getTabbedTextOffset(Segment s, FontMetrics metrics, int x0, int x, TabExpander e, int startOffset, boolean round)`
    `static int` | Utilities.`getTabbedTextWidth(Segment s, FontMetrics metrics, int x, TabExpander e, int startOffset)` Determines the width of the given segment of text taking tabs into consideration.
    `void` | AbstractDocument.`getText(int offset, int length, Segment txt)` Fetches the text contained within the given portion of the document.
    `void` | Document.`getText(int offset, int length, Segment txt)` Fetches the text contained within the given portion of the document.

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.