refactor contructor in swing