refactor paintComponent