void () { boolean oldVisible = myToolbar.isVisible(); boolean newVisible = isVisible(myActionGroup); myToolbar.setVisible(newVisible); if (oldVisible && newVisible) { myToolbar.getParent().revalidate(); } }