Package javax.swing

Examples of javax.swing.JMenu


  private static void addWindowMenu(final JFrame frame,
                                    final JMenuBar menuBar,
                                    final SweetHome3D homeApplication,
                                    boolean defaultFrame) {
    UserPreferences preferences = homeApplication.getUserPreferences();
    final JMenu windowMenu = new JMenu(
        new ResourceAction(preferences, MacOSXConfiguration.class, "WINDOW_MENU", true));
    // Add Window menu before Help menu
    menuBar.add(windowMenu, menuBar.getComponentCount() - 1);
    windowMenu.add(new JMenuItem(
        new ResourceAction(preferences, MacOSXConfiguration.class, "MINIMIZE", !defaultFrame) {
            @Override
            public void actionPerformed(ActionEvent ev) {
              frame.setState(JFrame.ICONIFIED);
            }
          }));
    windowMenu.add(new JMenuItem(
        new ResourceAction(preferences, MacOSXConfiguration.class, "ZOOM", !defaultFrame) {
            @Override
            public void actionPerformed(ActionEvent ev) {
              if ((frame.getExtendedState() & JFrame.MAXIMIZED_BOTH) != 0) {
                frame.setExtendedState(frame.getExtendedState() & ~JFrame.MAXIMIZED_BOTH);
              } else {
                frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
              }
            }
          }));
    windowMenu.addSeparator();
    windowMenu.add(new JMenuItem(
        new ResourceAction(preferences, MacOSXConfiguration.class, "BRING_ALL_TO_FRONT", !defaultFrame) {
            @Override
            public void actionPerformed(ActionEvent ev) {
              // Avoid blinking while bringing other windows to front
              frame.setAlwaysOnTop(true);
              for (Home home : homeApplication.getHomes()) {
                JFrame applicationFrame = homeApplication.getHomeFrame(home);
                if (applicationFrame != frame
                    && applicationFrame.getState() != JFrame.ICONIFIED) {
                  applicationFrame.setFocusableWindowState(false);
                  applicationFrame.toFront();
                  applicationFrame.setFocusableWindowState(true);
                }
              }
              frame.setAlwaysOnTop(false);
            }
          }));
   
    windowMenu.addMenuListener(new MenuListener() {
        public void menuSelected(MenuEvent ev) {
          boolean firstMenuItem = true;
          // Fill menu dynamically with a menu item for the frame of each application home
          for (Home home : homeApplication.getHomes()) {
            final JFrame applicationFrame = homeApplication.getHomeFrame(home);
            JCheckBoxMenuItem windowMenuItem = new JCheckBoxMenuItem(
                new AbstractAction(applicationFrame.getTitle()) {
                    public void actionPerformed(ActionEvent ev) {
                      applicationFrame.toFront();
                    }
                  });
             
            if (frame == applicationFrame) {
              windowMenuItem.setSelected(true);
            }
            if (firstMenuItem) {
              windowMenu.addSeparator();
              firstMenuItem = false;
            }
            windowMenu.add(windowMenuItem);
          }
        }

        public void menuDeselected(MenuEvent ev) {
          // Remove dynamically filled part of menu
          for (int i = windowMenu.getMenuComponentCount() - 1; i >= 4; i--) {
            windowMenu.remove(i);
          }
        }

        public void menuCanceled(MenuEvent ev) {
          menuDeselected(ev);
View Full Code Here


   *  
   * @return javax.swing.JMenu 
   */
  private JMenu getJMenu_file() {
    if (jMenu_file == null) {
      jMenu_file = new JMenu(LangageManager.getProperty("entaggedmenubar.filemenu"));
      jMenu_file.add(getJMenuItem_Exit());
    }
    return jMenu_file;
  }
View Full Code Here

   *  
   * @return javax.swing.JMenu 
   */
  private JMenu getJMenu_help() {
    if (jMenu_help == null) {
      jMenu_help = new JMenu(LangageManager.getProperty("entaggedmenubar.helpmenu"));
      jMenu_help.add(getJMenuItem_Help());
      jMenu_help.add(getJMenuItem_About());
    }
    return jMenu_help;
  }
View Full Code Here

   *  
   * @return javax.swing.JMenu 
   */
  private JMenu getJMenu_tools() {
    if (jMenu_tools == null) {
      jMenu_tools = new JMenu(LangageManager.getProperty("entaggedmenubar.toolsmenu"));
      jMenu_tools.add(getJMenuItem_Listing());
      jMenu_tools.add(getJMenuItem_Options());
      jMenu_tools.add(getJMenuItem_Statistics());
      jMenu_tools.add(getJMenuItem_Index());
      jMenu_tools.add(getJMenuItem_WrongInput());
View Full Code Here

    frame.setTitle("Microlog Bluetooth Server");
    {
      JMenuBar menuBar = new JMenuBar();
      frame.setJMenuBar(menuBar);
      {
        JMenu mnFile = new JMenu("File");
        menuBar.add(mnFile);
        {
          JMenuItem mntmSaveLogAs = new JMenuItem("Save Log As ...");
          mntmSaveLogAs.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              showSaveLogFileAsDialog();
            }
          });
          {
            JMenuItem mntmClearLog = new JMenuItem("Clear Log");
            mntmClearLog.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                getTextArea().setText("");
              }
            });
            mnFile.add(mntmClearLog);
          }
          mnFile.add(mntmSaveLogAs);
        }
        {
          JMenuItem mntmExit = new JMenuItem("Exit");
          mntmExit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.exit(0);
            }
          });
          mnFile.add(mntmExit);
        }
      }
      {
        JMenu mnHelp = new JMenu("Help");
        menuBar.add(mnHelp);
        {
          JMenuItem mntmBtAddress = new JMenuItem(
              "Server Bluetooth address");
          mntmBtAddress.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              JOptionPane.showMessageDialog(null, btAddress,
                  "Server Bluetooth address",
                  JOptionPane.INFORMATION_MESSAGE);
            }
          });
          mnHelp.add(mntmBtAddress);
          JMenuItem mntmAbout = new JMenuItem("About");
          mntmAbout.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              AboutDialog aboutDialog = new AboutDialog();
              aboutDialog.setModal(true);
              aboutDialog.setVisible(true);
            }
          });
          mnHelp.add(mntmAbout);
        }
      }
    }
    frame.setBounds(100, 100, 793, 499);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
View Full Code Here

    }

    private void initialize() {

      if (PersistenceManager.isPersistenceEnabled()) {
        changePriorityMenu = new JMenu();
            for(final FreenetPriority priority : FreenetPriority.values()) {
              JMenuItem priorityMenuItem = new JMenuItem();
              priorityMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(final ActionEvent actionEvent) {
                  changeItemPriorites(modelTable.getSelectedItems(), priority);
View Full Code Here

      if (PersistenceManager.isPersistenceEnabled()) {
        add(changePriorityMenu);
        addSeparator();
      }

      final JMenu enabledSubMenu = new JMenu(language
          .getString("DownloadPane.fileTable.popupmenu.enableDownloads")
          + "...");
      enabledSubMenu.add(enableSelectedDownloadsItem);
      enabledSubMenu.add(disableSelectedDownloadsItem);
      enabledSubMenu.add(invertEnabledSelectedItem);
      enabledSubMenu.addSeparator();

      enabledSubMenu.add(enableAllDownloadsItem);
      enabledSubMenu.add(disableAllDownloadsItem);
      enabledSubMenu.add(invertEnabledAllItem);
      add(enabledSubMenu);

      // we only find external items if persistence is enabled
      if (PersistenceManager.isPersistenceEnabled()) {
        for (final FrostDownloadItem item : selectedItems) {
View Full Code Here

        addNewDownloadsTable.removeButSelected();
      }
    });

    // Change Priority
    final JMenu changePriorityMenu = new JMenu(language.getString("Common.priority.changePriority"));
    for(final FreenetPriority priority : FreenetPriority.values()) {
      JMenuItem priorityMenuItem = new JMenuItem(priority.getName());
      priorityMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent actionEvent) {
          addNewDownloadsTable.new SelectedItemsAction() {
            protected void action(AddNewDownloadsTableMember addNewDownloadsTableMember) {
              addNewDownloadsTableMember.getDownloadItem().setPriority(priority);
            }
          };
        }
      });
      changePriorityMenu.add(priorityMenuItem);
    }
   
    // Enable download
    final JMenuItem enableDownloadMenuItem = new JMenuItem(language.getString("AddNewDownloadsDialog.popupMenu.enableDownload"));
    enableDownloadMenuItem.addActionListener( new java.awt.event.ActionListener() {
      public void actionPerformed(final ActionEvent actionEvent) {
        addNewDownloadsTable.new SelectedItemsAction() {
          protected void action(AddNewDownloadsTableMember addNewDownloadsTableMember) {
            addNewDownloadsTableMember.getDownloadItem().setEnabled(true);
          }
        };
      }
    });
   
   
    // Disable download
    final JMenuItem disableDownloadMenuItem = new JMenuItem(language.getString("AddNewDownloadsDialog.popupMenu.disableDownload"));
    disableDownloadMenuItem.addActionListener( new java.awt.event.ActionListener() {
      public void actionPerformed(final ActionEvent actionEvent) {
        addNewDownloadsTable.new SelectedItemsAction() {
          protected void action(AddNewDownloadsTableMember addNewDownloadsTableMember) {
            addNewDownloadsTableMember.getDownloadItem().setEnabled(false);
          }
        };
      }
    });
   
    // recent download directory
    final JMenu downloadDirRecentMenu = new JMenu(language.getString("DownloadPane.toolbar.downloadDirMenu.setDownloadDirTo"));
    JMenuItem item = new JMenuItem(Core.frostSettings.getValue(SettingsClass.DIR_DOWNLOAD));
    item.addActionListener( new java.awt.event.ActionListener() {
      public void actionPerformed(final ActionEvent actionEvent) {
        setDownloadDir(Core.frostSettings.getValue(SettingsClass.DIR_DOWNLOAD));
      }
    });
    downloadDirRecentMenu.add(item);
    final LinkedList<String> dirs = FileTransferManager.inst().getDownloadManager().getRecentDownloadDirs();
    if( dirs.size() > 0 ) {
      downloadDirRecentMenu.addSeparator();
      final ListIterator<String> iter = dirs.listIterator(dirs.size());
      while (iter.hasPrevious()) {
        final String dir = (String) iter.previous();
       
        item = new JMenuItem(dir);
        item.addActionListener( new java.awt.event.ActionListener() {
          public void actionPerformed(final ActionEvent actionEvent) {
            setDownloadDir(dir);
          }
        });
        downloadDirRecentMenu.add(item);
      }
    }

    // Compose popup menu
    tablePopupMenu = new JSkinnablePopupMenu();
View Full Code Here

      }
    });
   
   
    // Freenet compatibility mode
    final JMenu changeFreenetCompatibilityModeMenu = new JMenu(language.getString("AddNewUploadsDialog.popupMenu.changeFreenetCompatibilityMode"));
    for(final FreenetCompatibilityMode freenetCompatibilityMode : FreenetCompatibilityMode.values()) {
      JMenuItem changeFreenetCompatibilityModeMenutItem = new JMenuItem(freenetCompatibilityMode.toString());
      changeFreenetCompatibilityModeMenutItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent actionEvent) {
          addNewUploadsTable.new SelectedItemsAction() {
            protected void action(AddNewUploadsTableMember addNewUploadsTableMember) {
              addNewUploadsTableMember.getUploadItem().setFreenetCompatibilityMode(freenetCompatibilityMode);
            }
          };
        }
      });
      changeFreenetCompatibilityModeMenu.add(changeFreenetCompatibilityModeMenutItem);
    }
   
   
    // Change Priority
    final JMenu changePriorityMenu = new JMenu(language.getString("Common.priority.changePriority"));
    for(final FreenetPriority priority : FreenetPriority.values()) {
      JMenuItem priorityMenuItem = new JMenuItem(priority.getName());
      priorityMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent actionEvent) {
          addNewUploadsTable.new SelectedItemsAction() {
            protected void action(AddNewUploadsTableMember addNewUploadsTableMember) {
              addNewUploadsTableMember.getUploadItem().setPriority(priority);
            }
          };
        }
      });
      changePriorityMenu.add(priorityMenuItem);
    }
   
    // Enable upload
    final JMenuItem enableUploadMenuItem = new JMenuItem(language.getString("AddNewUploadsDialog.popupMenu.enableUpload"));
    enableUploadMenuItem.addActionListener( new java.awt.event.ActionListener() {
View Full Code Here

        bar = new JMenuBar();
        if (!isOnlyViewer)
            setJMenuBar(bar);
        // Allocation of the menus
        mProject = new JMenu();
        mMRU = new JMenu();
        mMRU.setIcon(new ImageIcon(getClass().getResource(
                "/icons/recent_16.gif")));
        mEdit = new JMenu();
        // mView = new JMenu ();
        mTask = new JMenu();
        mHuman = new JMenu();
        mHelp = new JMenu();
        mCalendar = new JMenu();
        miUndo = new JMenuItem(new UndoAction(getUndoManager(), "16", this));
        mEdit.add(miUndo);
        // miUndo.setEnabled(false);
        miRedo = new JMenuItem(new RedoAction(getUndoManager(), "16", this));
        mEdit.add(miRedo);
        // miRedo.setEnabled(false);
        mEdit.addSeparator();

        createProjectMenu();

        miRefresh = new JMenuItem(myRefreshAction);
        // miRefresh.setAccelerator((KeyStroke)myRefreshAction.getValue(Action.ACCELERATOR_KEY));
        mEdit.add(miRefresh);
        mEdit.addSeparator();

        //miCut = new JMenuItem(myCutAction);
        mEdit.add(getViewManager().getCutAction());
        //miCopy = new JMenuItem(myCopyAction);
        mEdit.add(getViewManager().getCopyAction());
        //miPaste = new JMenuItem(myPasteAction);
        mEdit.add(getViewManager().getPasteAction());
        mEdit.addSeparator();
        miOptions = createNewItem("/icons/settings_16.gif");
        mEdit.add(miOptions);
        myNewTaskAction = new NewTaskAction((IGanttProject) this);
        mTask.add(myNewTaskAction);
        miDeleteTask = createNewItem("/icons/delete_16.gif");
        mTask.add(miDeleteTask);
        myTaskPropertiesAction = new TaskPropertiesAction(getProject(), Mediator.getTaskSelectionManager(), getUIFacade());
        mTask.add(myTaskPropertiesAction);
        getTree().setTaskPropertiesAction(myTaskPropertiesAction);
        getResourcePanel().setTaskPropertiesAction(myTaskPropertiesAction);
        //
        //
        myNewHumanAction = new NewHumanAction(getHumanResourceManager(),
                getRoleManager(), this, this) {
            public void actionPerformed(ActionEvent event) {
                super.actionPerformed(event);
                getTabs().setSelectedIndex(UIFacade.RESOURCES_INDEX);
            }
        };


        mHuman.add(myNewHumanAction);
        myDeleteHumanAction = getResourceActions().getDeleteHumanAction();
        miDelHuman = new JMenuItem(myDeleteHumanAction);
        mHuman.add(miDelHuman);
        //miPropHuman = createNewItem("/icons/properties_16.gif");
        //mHuman.add(miPropHuman);
        mHuman.add(getResourcePanel().getResourcePropertiesAction());
        miSendMailHuman = createNewItem("/icons/send_mail_16.gif");
        mHuman.add(miSendMailHuman);

        mHuman.add(new ImportResources(getHumanResourceManager(),
                getTaskManager(), getRoleManager(), this));

        miEditCalendar = createNewItem("/icons/clock_16.gif");
        mCalendar.add(miEditCalendar);
        miPrjCal = createNewItem("/icons/default_calendar_16.gif");
        mCalendar.add(miPrjCal);
        miWebPage = createNewItem("/icons/home_16.gif");
        mHelp.add(miWebPage);
        miManual = createNewItem("/icons/help_16.gif");
        try { // See if helpgui library is on the classpath
            Class.forName("net.sourceforge.helpgui.HelpGui");
            mHelp.add(miManual);
            miManual.setAccelerator(KeyStroke.getKeyStroke("F1"));
        } catch (Exception ex) {
            // Not add the help button on the ui
        }
        miTips = createNewItem("/icons/about_16.gif");
        mHelp.add(miTips);
        miAbout = createNewItem("/icons/manual_16.gif");
        mHelp.add(miAbout);
        if (!isApplet) {
            bar.add(mProject); // for a applet veiwer, Project menu is not
            // neccessary By CL
        }
        bar.add(mEdit);
        JMenu viewMenu = createViewMenu();
        if (viewMenu != null)
            bar.add(viewMenu);
        // bar.add (mView);
        bar.add(mTask);
        bar.add(mHuman);
View Full Code Here

TOP

Related Classes of javax.swing.JMenu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.