コード例 #1
0
 /**
  * Add a MenuItem to this MenuItem
  *
  * @param childMenuItem the MenuItem we want to add
  */
 public void add(SwingScilabMenuItem childMenuItem) {
   System.out.println("SwingScilabMenuItem.add(SwingScilabMenuItem childMenuItem)");
   if (meAsAMenu == null) {
     meAsAMenu = ScilabMenu.createMenu();
     meAsAMenu.setText(getText());
     ((SwingScilabMenu) meAsAMenu.getAsSimpleMenu()).add(childMenuItem);
     if (meAsACheckBoxMenuItem == null) {
       Container parent = getParent();
       int index = parent.getComponentZOrder(this);
       parent.remove(this.getComponent());
       parent.add((SwingScilabMenu) meAsAMenu.getAsSimpleMenu(), index);
     } else {
       Container parent =
           ((SwingScilabCheckBoxMenuItem) meAsACheckBoxMenuItem.getAsSimpleCheckBoxMenuItem())
               .getParent();
       int index =
           parent.getComponentZOrder(
               ((SwingScilabCheckBoxMenuItem)
                   meAsACheckBoxMenuItem.getAsSimpleCheckBoxMenuItem()));
       parent.remove(
           ((SwingScilabCheckBoxMenuItem) meAsACheckBoxMenuItem.getAsSimpleCheckBoxMenuItem())
               .getComponent());
       parent.add((SwingScilabMenu) meAsAMenu.getAsSimpleMenu(), index);
     }
   } else {
     ((SwingScilabMenu) meAsAMenu.getAsSimpleMenu()).add(childMenuItem);
   }
 }
コード例 #2
0
 /**
  * Append a CheckBoxMenuItem to a Scilab Menu
  *
  * @param newCheckBoxMenuItem the CheckBoxMenuItem to add to the Menu
  * @see org.scilab.modules.gui.menu.Menu#add(org.scilab.modules.gui.CheckBoxMenuItem)
  */
 public void add(CheckBoxMenuItem newCheckBoxMenuItem) {
   if (meAsAMenu == null) {
     meAsAMenu = ScilabMenu.createMenu();
     meAsAMenu.setText(getText());
     meAsAMenu.add(newCheckBoxMenuItem);
     Container parent = getParent();
     int index = parent.getComponentZOrder(this);
     parent.remove(this.getComponent());
     parent.add((SwingScilabMenu) meAsAMenu.getAsSimpleMenu(), index);
   } else {
     meAsAMenu.add(newCheckBoxMenuItem);
   }
 }
コード例 #3
0
 /**
  * Set if the Menu is checked or not
  *
  * @param status true if the Menu is checked
  */
 public void setChecked(boolean status) {
   checkedState = status;
   if (meAsACheckBoxMenuItem == null) {
     meAsACheckBoxMenuItem = ScilabCheckBoxMenuItem.createCheckBoxMenuItem(autoCheckedMode);
     meAsACheckBoxMenuItem.setText(getText());
     meAsACheckBoxMenuItem.setChecked(status);
     meAsACheckBoxMenuItem.setCallback(getCallback());
     Container parent = getParent();
     int index = parent.getComponentZOrder(this);
     parent.remove(this.getComponent());
     parent.add(
         (SwingScilabCheckBoxMenuItem) meAsACheckBoxMenuItem.getAsSimpleCheckBoxMenuItem(), index);
   } else {
     meAsACheckBoxMenuItem.setChecked(status);
   }
 }