AnAction (Project project, JTree tree, final AutoScrollToSourceOptionProvider optionProvider) { AutoScrollToSourceHandler handler = new AutoScrollToSourceHandler() { @Override public boolean isAutoScrollMode() { return optionProvider.isAutoScrollMode(); } @Override public void setAutoScrollMode(boolean state) { optionProvider.setAutoScrollMode(state); } }; handler.install(tree); return handler.createToggleAction(); }