Use an inner object to implement the PanelWorld class instead of implementing JPanel logic directly in the World class