Implemented a Factory for creating UI elements.