Your problem is that your method is declared to return Component
type, and if you look in the API for this class, you'll see that it does not have a setToolTipText(...)
method. This method begins in the JComponent class. One solution is to have the Map only collect JComponents and have the method declared to return this type. Incidentally, if you declare your Map with generic parameters, you won't have to do your cast.
i.e., rather than this declaration,
private HashMap componentMap;
use,
private HashMap<String, Component> componentMap;
or if again if this will work for you:
private HashMap<String, JComponent> componentMap;