public DaylightTracker2() {
    // This code is automatically generated by Visual Cafe when you add
    // components to the visual environment. It instantiates and initializes
    // the components. To modify the code, only use code syntax that matches
    // what Visual Cafe can generate, or Visual Cafe may be unable to back
    // parse your Java file into its visual environment.
    // {{INIT_CONTROLS
    getContentPane().setLayout(new BorderLayout());
    setSize(560, 300);
    setTitle("Day and Night");
    // }}

    // setResizable(false);

    JPanel theRealBasePanel = new JPanel();
    theRealBasePanel.setLayout(new MultiCompBorderLayout());
    getContentPane().add(theRealBasePanel);

    MenuBar theMenuBar = new MenuBar();
    setMenuBar(theMenuBar);

    theMenuBar.add(fileMenu = new Menu("File"));
    fileMenu.add(file_quitItem = new MenuItem("Quit"));

    theMenuBar.add(editMenu = new Menu("Edit"));
    editMenu.add(edit_undoItem = new MenuItem("Undo"));
    edit_undoItem.setEnabled(false);
    editMenu.add(new MenuItem("-"));
    editMenu.add(edit_cutItem = new MenuItem("Cut"));
    edit_cutItem.setEnabled(false);
    editMenu.add(edit_copyItem = new MenuItem("Copy"));
    edit_copyItem.setEnabled(false);
    editMenu.add(edit_pasteItem = new MenuItem("Paste"));
    edit_pasteItem.setEnabled(false);
    editMenu.add(edit_clearItem = new MenuItem("Clear"));
    edit_clearItem.setEnabled(false);
    editMenu.add(new MenuItem("-"));
    editMenu.add(edit_prefsItem = new MenuItem("Preferences..."));

    theMenuBar.add(layersMenu = new Menu("Layers"));

    theMenuBar.setHelpMenu(helpMenu = new Menu("Help"));
    helpMenu.add(help_aboutItem = new MenuItem("About JSunTool..."));

    allMapLayers.addElement(new OverlayedTimeLayer());
    allMapLayers.addElement(new NightDay());
    allMapLayers.addElement(new GeographicalMap());
    allMapLayers.addElement(new TopographicalMap());

    menuMapLayers = new CheckboxMenuItem[allMapLayers.size()];

    CheckboxMenuActionListener theCheckboxMenuActionListener = new CheckboxMenuActionListener();

    for (int i = 0; i < allMapLayers.size(); i++) {

      visibleMapLayers.addElement(allMapLayers.elementAt(i));
      theRealBasePanel.add((Component) (visibleMapLayers.elementAt(i)));

      // CheckboxMenuItem tempMenuItem
      menuMapLayers[i] =
          new CheckboxMenuItem(((MapLayer) (allMapLayers.elementAt(i))).getShortName(), true);
      menuMapLayers[i].setActionCommand(new String("MapLayer." + i));
      menuMapLayers[i].addItemListener(theCheckboxMenuActionListener);
      layersMenu.add(menuMapLayers[i]);
    }

    // {{INIT_MENUS
    // }}

    // {{REGISTER_LISTENERS
    SymWindow aSymWindow = new SymWindow();
    this.addWindowListener(aSymWindow);
    // }}

    // Timer theTimer = new Timer ( 1800000, new TimerActionListener() );
    //		Timer theTimer = new Timer ( 1000, new TimerActionListener() );
    //		theTimer.start();
    (new Thread(this)).start();

    MenuActionListener theMenuActionListener = new MenuActionListener();
    file_quitItem.addActionListener(theMenuActionListener);
    help_aboutItem.addActionListener(theMenuActionListener);
  }
Beispiel #2
0
  private void initMenu(String initialMessage) {
    // Create
    menu = new PopupMenu();

    // Status
    itemStatus = new MenuItem(initialMessage);
    itemStatus.setEnabled(false);

    menu.add(itemStatus);

    // Profile and folders
    menu.addSeparator();

    Profile profile = config.getProfile();

    final Folder folder = profile.getFolder();
    if (folder != null && folder.isActive() && folder.getLocalFile() != null) {

      MenuItem itemFolder = new MenuItem(folder.getLocalFile().getName());

      itemFolder.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
              fireTrayEvent(
                  new TrayEvent(
                      TrayEvent.EventType.OPEN_FOLDER, folder.getLocalFile().getAbsolutePath()));
            }
          });

      menu.add(itemFolder);
    }

    menu.addSeparator();

    // Preferences
    // itemPreferences = new MenuItem("Preferencias ...");
    // itemPreferences.addActionListener(new ActionListener() {

    //    @Override
    //    public void actionPerformed(ActionEvent ae) {
    //        fireTrayEvent(new TrayEvent(TrayEvent.EventType.PREFERENCES));
    //    }
    // });

    // menu.add(itemPreferences);

    // menu.addSeparator();
    itemWebsite = new MenuItem(resourceBundle.getString("tray_stacksync_website"));
    itemWebsite.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent ae) {
            fireTrayEvent(new TrayEvent(TrayEvent.EventType.WEBSITE));
          }
        });
    menu.add(itemWebsite);

    itemWebsite2 = new MenuItem(resourceBundle.getString("tray_ast_website"));
    itemWebsite2.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent ae) {
            fireTrayEvent(new TrayEvent(TrayEvent.EventType.WEBSITE2));
          }
        });
    menu.add(itemWebsite2);

    menu.addSeparator();

    // Quit
    itemQuit = new MenuItem(resourceBundle.getString("tray_exit"));
    itemQuit.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent ae) {
            fireTrayEvent(new TrayEvent(TrayEvent.EventType.QUIT));
          }
        });

    menu.add(itemQuit);
  }