//
  //  Initialize the GUI (application and applet)
  //
  public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D Light Scoping Example");

    //
    //  Add a menubar menu to change node parameters
    //    Use bounding leaf
    //

    Menu m = new Menu("DirectionalLights");

    light1OnOffMenu = new CheckboxMenuItem("Red light with sphere set 1 scope", light1OnOff);
    light1OnOffMenu.addItemListener(this);
    m.add(light1OnOffMenu);

    light2OnOffMenu = new CheckboxMenuItem("Blue light with sphere set 2 scope", light2OnOff);
    light2OnOffMenu.addItemListener(this);
    m.add(light2OnOffMenu);

    light3OnOffMenu = new CheckboxMenuItem("White light with universal scope", light3OnOff);
    light3OnOffMenu.addItemListener(this);
    m.add(light3OnOffMenu);

    exampleMenuBar.add(m);
  }
Example #2
0
  public MenuFrame(String title) {
    super(title);
    this.m_file = new Menu("File");
    this.m_edit = new Menu("Edit");
    this.cm_debug = new CheckboxMenuItem("Debug");
    this.cm_test = new CheckboxMenuItem("Test");
    this.p_debug = new Panel();

    MenuFrameListener listener = new MenuFrameListener();

    Menu m_sub = new Menu("Additional");
    MenuItem mi_new = new MenuItem("New...");
    MenuItem mi_open = new MenuItem("Open...");
    MenuItem mi_close = new MenuItem("Close...");
    MenuItem mi_cut = new MenuItem("Cut");
    MenuItem mi_copy = new MenuItem("Copy");
    MenuItem mi_paste = new MenuItem("Paste");
    MenuItem mi_one = new MenuItem("One!");
    MenuItem mi_two = new MenuItem("Two!");
    MenuItem mi_three = new MenuItem("Three!");

    mi_new.addActionListener(listener);
    mi_open.addActionListener(listener);
    mi_close.addActionListener(listener);
    mi_cut.addActionListener(listener);
    mi_copy.addActionListener(listener);
    mi_paste.addActionListener(listener);
    mi_one.addActionListener(listener);
    mi_two.addActionListener(listener);
    mi_three.addActionListener(listener);
    cm_debug.addItemListener(listener);
    cm_test.addItemListener(listener);

    m_sub.add(mi_one);
    m_sub.add(mi_two);
    m_sub.add(mi_three);
    m_file.add(mi_open);
    m_file.add(mi_new);
    m_file.add(mi_close);
    m_edit.add(mi_cut);
    m_edit.add(mi_copy);
    m_edit.add(mi_paste);
    m_edit.add(m_sub);
    m_edit.add(cm_test);
    m_edit.add(cm_debug);

    initWindow();
  }
Example #3
0
  //
  //  Initialize the GUI (application and applet)
  //
  public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D LinearFog Example");

    //
    //  Add a menubar menu to change node parameters
    //    Coupled background color
    //    Background color -->
    //    Fog color -->
    //    Fog front distance -->
    //    Fog back distance -->
    //

    Menu m = new Menu("LinearFog");

    coupledBackgroundOnOffMenu =
        new CheckboxMenuItem("Couple background color", coupledBackgroundOnOff);
    coupledBackgroundOnOffMenu.addItemListener(this);
    m.add(coupledBackgroundOnOffMenu);

    backgroundColorMenu =
        new CheckboxMenu("Background color", colors, currentBackgroundColor, this);
    m.add(backgroundColorMenu);
    backgroundColorMenu.setEnabled(!coupledBackgroundOnOff);

    colorMenu = new CheckboxMenu("Fog color", colors, currentColor, this);
    m.add(colorMenu);

    frontMenu = new CheckboxMenu("Fog front distance", fronts, currentFront, this);
    m.add(frontMenu);

    backMenu = new CheckboxMenu("Fog back distance", backs, currentBack, this);
    m.add(backMenu);

    exampleMenuBar.add(m);
  }
Example #4
0
  /** Initializes the frame menu. */
  private void initializeMenu() {
    Menu menu;
    MenuItem item;

    // Create file menu
    menu = new Menu("File");
    item = new MenuItem("Load MIB...", new MenuShortcut(KeyEvent.VK_O));
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            loadMib();
          }
        });
    menu.add(item);
    item = new MenuItem("Unload MIB", new MenuShortcut(KeyEvent.VK_W));
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            unloadMib();
          }
        });
    menu.add(item);
    item = new MenuItem("Unload All");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            unloadAllMibs();
          }
        });
    menu.add(item);
    if (!MacUIHelper.IS_MAC_OS) {
      menu.addSeparator();
      item = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_Q));
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              quit();
            }
          });
      menu.add(item);
    }
    menuBar.add(menu);

    // Create Edit menu
    menu = new Menu("Edit");
    item = new MenuItem("Cut", new MenuShortcut(KeyEvent.VK_X));
    item.addActionListener(new DefaultEditorKit.CutAction());
    menu.add(item);
    item = new MenuItem("Copy", new MenuShortcut(KeyEvent.VK_C));
    item.addActionListener(new DefaultEditorKit.CopyAction());
    menu.add(item);
    item = new MenuItem("Paste", new MenuShortcut(KeyEvent.VK_V));
    item.addActionListener(new DefaultEditorKit.PasteAction());
    menu.add(item);
    item = new MenuItem("Select All", new MenuShortcut(KeyEvent.VK_A));
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
            Component comp = kfm.getFocusOwner();
            if (comp instanceof TextComponent) {
              ((TextComponent) comp).selectAll();
            } else if (comp instanceof JTextComponent) {
              ((JTextComponent) comp).selectAll();
            }
          }
        });
    menu.add(item);
    menuBar.add(menu);

    // Create SNMP menu
    menu = new Menu("SNMP");
    snmpV1Item.setState(true);
    snmpV1Item.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            setSnmpVersion(1);
          }
        });
    menu.add(snmpV1Item);
    snmpV2Item.setState(false);
    snmpV2Item.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            setSnmpVersion(2);
          }
        });
    menu.add(snmpV2Item);
    snmpV3Item.setState(false);
    snmpV3Item.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            setSnmpVersion(3);
          }
        });
    menu.add(snmpV3Item);
    menu.addSeparator();
    CheckboxMenuItem checkBox = new CheckboxMenuItem("Show result in tree");
    checkBox.setState(true);
    checkBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            setSnmpFeedback(e.getStateChange() == ItemEvent.SELECTED);
          }
        });
    menu.add(checkBox);
    menuBar.add(menu);

    // Create help menu
    menu = new Menu("Help");
    item = new MenuItem("License...");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            showLicense();
          }
        });
    menu.add(item);
    if (!MacUIHelper.IS_MAC_OS) {
      item = new MenuItem("About...");
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              showAbout();
            }
          });
      menu.add(item);
    }
    menuBar.add(menu);

    // Fix Mac OS specific menus
    if (MacUIHelper.IS_MAC_OS) {
      @SuppressWarnings("unused")
      Object tmp = new MacUIHelper(this);
    }
  }
Example #5
0
  private void init(final SettingsUI settingsUI) throws AWTException {
    SystemTray tray = SystemTray.getSystemTray();

    PopupMenu popup = new PopupMenu();

    final CheckboxMenuItem ftpItem = new CheckboxMenuItem(" Ftp ");
    final CheckboxMenuItem picasawebItem = new CheckboxMenuItem(" Picasaweb ");

    ftpItem.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            Settings.getInstance().setPicasawebMode(false);
            Settings.getInstance().save();
            start();
          }
        });
    popup.add(ftpItem);

    picasawebItem.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            Settings.getInstance().setPicasawebMode(true);
            Settings.getInstance().save();
            start();
          }
        });
    popup.add(picasawebItem);

    checkMenuItem(picasawebItem, ftpItem, Settings.getInstance().isPicasawebMode());

    MenuItem settingsItem = new MenuItem(" Settings ");
    settingsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            settingsUI.open(mousePoint);
          }
        });
    popup.add(settingsItem);

    MenuItem exitItem = new MenuItem(" Exit ");
    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.out.println("Exiting...");
            System.exit(0);
          }
        });
    popup.add(exitItem);

    URL imgURL = getClass().getClassLoader().getResource("icon.png");
    final TrayIcon trayIcon = new TrayIcon(new ImageIcon(imgURL).getImage(), "Screenshot", popup);

    trayIcon.setImageAutoSize(true);
    trayIcon.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            checkMenuItem(picasawebItem, ftpItem, Settings.getInstance().isPicasawebMode());
          }

          public void mouseClicked(MouseEvent e) {
            mousePoint = e.getPoint();
            if (e.getButton() == BUTTON1) {
              start();
            }
          }
        });

    tray.add(trayIcon);
  }
  private static void createAndShowGUI() {
    // Check the SystemTray support
    if (!SystemTray.isSupported()) {
      System.out.println("SystemTray is not supported");
      return;
    }
    final PopupMenu popup = new PopupMenu();
    final TrayIcon trayIcon =
        new TrayIcon(ImageHelper.loadImage("/images/splash.jpg", "tray icon"));
    final SystemTray tray = SystemTray.getSystemTray();

    // Create a popup menu components
    MenuItem aboutItem = new MenuItem("About");
    CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size");
    CheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip");
    Menu displayMenu = new Menu("Display");
    MenuItem errorItem = new MenuItem("Error");
    MenuItem warningItem = new MenuItem("Warning");
    MenuItem infoItem = new MenuItem("Info");
    MenuItem noneItem = new MenuItem("None");
    MenuItem exitItem = new MenuItem("Exit");

    // Add components to popup menu
    popup.add(aboutItem);
    popup.addSeparator();
    popup.add(cb1);
    popup.add(cb2);
    popup.addSeparator();
    popup.add(displayMenu);
    displayMenu.add(errorItem);
    displayMenu.add(warningItem);
    displayMenu.add(infoItem);
    displayMenu.add(noneItem);
    popup.add(exitItem);

    trayIcon.setPopupMenu(popup);

    try {
      tray.add(trayIcon);
    } catch (AWTException e) {
      System.out.println("TrayIcon could not be added.");
      return;
    }

    trayIcon.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "This dialog box is run from System Tray");
          }
        });

    aboutItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null, "This dialog box is run from the About menu item");
          }
        });

    cb1.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            int cb1Id = e.getStateChange();
            if (cb1Id == ItemEvent.SELECTED) {
              trayIcon.setImageAutoSize(true);
            } else {
              trayIcon.setImageAutoSize(false);
            }
          }
        });

    cb2.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            int cb2Id = e.getStateChange();
            if (cb2Id == ItemEvent.SELECTED) {
              trayIcon.setToolTip("Sun TrayIcon");
            } else {
              trayIcon.setToolTip(null);
            }
          }
        });

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MenuItem item = (MenuItem) e.getSource();
            // TrayIcon.MessageType type = null;
            System.out.println(item.getLabel());
            if ("Error".equals(item.getLabel())) {
              // type = TrayIcon.MessageType.ERROR;
              trayIcon.displayMessage(
                  "Sun TrayIcon Demo", "This is an error message", TrayIcon.MessageType.ERROR);

            } else if ("Warning".equals(item.getLabel())) {
              // type = TrayIcon.MessageType.WARNING;
              trayIcon.displayMessage(
                  "Sun TrayIcon Demo", "This is a warning message", TrayIcon.MessageType.WARNING);

            } else if ("Info".equals(item.getLabel())) {
              // type = TrayIcon.MessageType.INFO;
              trayIcon.displayMessage(
                  "Sun TrayIcon Demo", "This is an info message", TrayIcon.MessageType.INFO);

            } else if ("None".equals(item.getLabel())) {
              // type = TrayIcon.MessageType.NONE;
              trayIcon.displayMessage(
                  "Sun TrayIcon Demo", "This is an ordinary message", TrayIcon.MessageType.NONE);
            }
          }
        };

    errorItem.addActionListener(listener);
    warningItem.addActionListener(listener);
    infoItem.addActionListener(listener);
    noneItem.addActionListener(listener);

    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            tray.remove(trayIcon);
            System.exit(0);
          }
        });
  }