refactoring trying to capture screenshot by Java Robot