Exemple #1
0
    public DemoControls(Gradient demo) {
      super(demo.name);
      this.demo = demo;
      JMenuBar inMenuBar = new JMenuBar();
      add(inMenuBar);
      JMenuBar outMenuBar = new JMenuBar();
      add(outMenuBar);
      Font font = new Font("serif", Font.PLAIN, 10);

      imenu = (JMenu) inMenuBar.add(new JMenu("Inner Color"));
      imenu.setFont(font);
      imenu.setIcon(new ColoredSquare(demo.innerC));
      omenu = (JMenu) outMenuBar.add(new JMenu("Outer Color"));
      omenu.setFont(font);
      omenu.setIcon(new ColoredSquare(demo.outerC));
      for (int i = 0; i < colors.length; i++) {
        squares[i] = new ColoredSquare(colors[i]);
        innerMI[i] = imenu.add(new JMenuItem(colorName[i]));
        innerMI[i].setFont(font);
        innerMI[i].setIcon(squares[i]);
        innerMI[i].addActionListener(this);
        outerMI[i] = omenu.add(new JMenuItem(colorName[i]));
        outerMI[i].setFont(font);
        outerMI[i].setIcon(squares[i]);
        outerMI[i].addActionListener(this);
      }
    }
Exemple #2
0
 public void actionPerformed(ActionEvent e) {
   for (int i = 0; i < colors.length; i++) {
     if (e.getSource().equals(innerMI[i])) {
       demo.innerC = colors[i];
       imenu.setIcon(squares[i]);
       break;
     } else if (e.getSource().equals(outerMI[i])) {
       demo.outerC = colors[i];
       omenu.setIcon(squares[i]);
       break;
     }
   }
   demo.repaint();
 }
  /**
   * Gets the <tt>JMenu</tt> which is the component of this plug-in. If it still doesn't exist, it's
   * created.
   *
   * @return the <tt>JMenu</tt> which is the component of this plug-in
   */
  private JMenu getMenu() {
    if (menu == null) {
      menu = new SIPCommMenu();
      menu.setText(getName());

      if (Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.equals(getContainer())) {
        Icon icon = OtrActivator.resourceService.getImage("plugin.otr.MENU_ITEM_ICON_16x16");

        if (icon != null) menu.setIcon(icon);
      }

      if (!inMacOSXScreenMenuBar) menu.getPopupMenu().addPopupMenuListener(this);
    }
    return menu;
  }