Refactored the component factory to provide a general create button factory method.