@Override
	public String getBeforeIndex(int part, int index) {
		String text = field.getText();
		if (index < 1 || index > text.length()) {
			return null;
		}

		switch (part) {
			case AccessibleText.CHARACTER:
				return text.substring(index - 1, index);
			case AccessibleText.WORD:
				BreakIterator words = BreakIterator.getWordInstance(locale);
				words.setText(text);

				// move to the beginning of the current word so the algorithm
				// gives us the previous word and not the word we are on. Note: this is needed
				// because the preceding() method behaves differently if in the middle of a
				// word than if at the beginning of the word.
				if (!words.isBoundary(index)) {
					words.preceding(index);
				}
				int start = words.previous();
				int end = words.next();
				if (start == BreakIterator.DONE) {
					return null;
				}
				return text.substring(start, end);
			case AccessibleText.SENTENCE:
				BreakIterator sentences = BreakIterator.getSentenceInstance(locale);
				sentences.setText(text);
				if (!sentences.isBoundary(index)) {
					sentences.preceding(index);
				}
				start = sentences.previous();
				end = sentences.next();
				if (start == BreakIterator.DONE) {
					return null;
				}
				return text.substring(start, end);
			default:
				return null;
		}
	}
Returns the field associated with this AccessibleField.
@return the field associated with this AccessibleField
Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/AccessibleField.java