Your example of typecasting should work, but I'd suggest a better name for the jComponent.

This line is the completion of the other approach:

frame.getContentPane().add(yellowLabel,...