void () { if (myController.canManageRepositories()) { myManageButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { ManageRepoDialog dialog = new ManageRepoDialog(myProject, myController); dialog.show(); } }); } else { myManageButton.setVisible(false); } }