private boolean touchesText(int x) {

		FontMetrics fm = textField.getFontMetrics(textField.getFont());

		Rectangle textBounds = textField.getBounds();
		Point location = textBounds.getLocation();

		String text = textField.getText();
		Rectangle2D bounds = fm.getStringBounds(text, textField.getGraphics());
		double textWidth = bounds.getWidth() + bounds.getX();

		int padding = 5;
		if (location.x + textWidth + padding > x) {
			return true;
		}
		return false;
	}
A label that displays an icon that, when clicked, will clear the contents of the 
associated filter.
Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/ClearFilterLabel.java