private void lazyDeriveSourceComponent() {

		if (sourceComponent != null) {
			// Do not allow this to change once set.  This prevents the value from getting changed
			// when the user clicks a menu item.
			return;
		}

		// check this in order of preference
		if (sourceObject instanceof Component) {
			sourceComponent = (Component) sourceObject;
			return;
		}

		if (mouseEvent != null) {
			sourceComponent = mouseEvent.getComponent();
			return;
		}

		if (contextObject instanceof Component) {
			sourceComponent = (Component) contextObject;
		}
	}
Constructor

@param provider the ComponentProvider that generated this context.
@param contextObject an optional contextObject that the ComponentProvider can provide; this 
       can be anything that actions wish to later retrieve
@param sourceComponent an optional source object; this is intended to be the component that
       is the source of the context, usually the focused component
Ghidra/Framework/Docking/src/main/java/docking/DefaultActionContext.java