public boolean getToolbarViewState(String toolbarName) throws Exception {
    Boolean state = true;
    JFrameOperator app = new JFrameOperator("JSystem");
    JMenuItemOperator menuItem = chooseMenuItem(app, false, "View", "Toolbars", toolbarName);
    Component checkBox = menuItem.getSource();
    if (checkBox instanceof JCheckBoxMenuItem) {
      state = ((JCheckBoxMenuItem) checkBox).isSelected();
    } else {
      throw new Exception(toolbarName + "Toolbar menu item is not a checkbox");
    }

    Robot r = new Robot();
    r.keyPress(KeyEvent.VK_ESCAPE);
    r.keyPress(KeyEvent.VK_ESCAPE);

    return state;
  }
  private JMenuItemOperator chooseMenuItem(
      JFrameOperator mainFrame, boolean pushLastLevel, Object... menuNames) throws Exception {
    int waitBetweenItems = 1000;
    JMenuItemOperator selectedItem = null;

    for (int index = 0; index < menuNames.length; index++) {

      String name = (String) menuNames[index];
      selectedItem = new JMenuItemOperator(mainFrame, name);
      // Push every level, and the last level only if asked
      if ((index != menuNames.length - 1) || pushLastLevel) {
        // Pushing "no block" since in some cases we just want to see the
        // sub menu and not make an action
        selectedItem.pushNoBlock();
      }
      Thread.sleep(waitBetweenItems);
    }
    return selectedItem;
  }