Refactor AWTListener into an inner class