private void paintCursor(JComponent c, Graphics g, Color cursorColor, RowColLocation cursorLoc,
			boolean cursorHidden) {
		if (cursorLoc == null) {
			return;
		}

		if (cursorLoc.col() >= numCols) {
			return;
		}

		g.setColor(cursorColor);

		int x = startX + metrics.stringWidth(text.substring(0, cursorLoc.col()));
		g.fillRect(x, -heightAbove, cursorWidth, heightAbove + heightBelow);

		if (cursorHidden) {
			return; // no cursor showing; no text to repaint
		}

		// paint the text above the cursor so it is not hidden
		Shape oldClip = g.getClip();
		try {
			g.setClip(x, -heightAbove, cursorWidth, heightAbove + heightBelow);
			Color textColor = ColorUtils.contrastForegroundColor(cursorColor);
			g.setColor(textColor);
			GraphicsUtils.drawString(c, g, text, startX, 0);
		}
		finally {
			g.setClip(oldClip);
		}
	}
Constructor
@param text the text value to display
@param fontMetrics the font to use to display the text.
@param startX the starting horizontal position of the field.
@param startY the starting vertical position of the field.
@param width the width of the field.
@param allowCursorAtEnd if true, the cursor will be allowed at the end of the field.
@param fieldOffset the column position of the fieldFactory that generated this field.
@param index the field's index
@param hlFactory the factory used to create highlights
Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteField.java