You are. e.getComponent() returns an object of type Component. Without the cast, there is a compiler error