private JButton toolkitButton(TransformationPage page) {
JPopupMenu popup = createToolkitPopupMenu(page);
final PopupMenuButton toolkit = new PopupMenuButton("", getToolkitIcon(), popup);
// HACK: If we don't dispose the toolkit button when the page is closed the page is never
// garbage collected. This shouldn't be necessary, and we should look into what causes this.
page.addResource(new AbstractWindowElementResource() {
@Override
public void dispose(WindowElement e) {
toolkit.dispose();
}