Java Code Examples for javax.swing.JMenu#setIcon()

The following examples show how to use javax.swing.JMenu#setIcon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShapeSet.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Populate the given menu with a hierarchy of all shapes,
 * organized by defined ShapeSets.
 *
 * @param top      the JComponent to populate (typically a JMenu or a JPopupMenu)
 * @param listener the listener for notification of user selection
 */
public static void addAllShapes (JComponent top,
                                 ActionListener listener)
{
    // All ranges of glyph shapes
    for (Field field : ShapeSet.class.getDeclaredFields()) {
        if (field.getType() == ShapeSet.class) {
            ShapeSet set = ShapeSet.valueOf(field.getName());
            JMenu menu = new JMenu(field.getName());

            if (set.rep != null) {
                menu.setIcon(set.rep.getDecoratedSymbol());
            }

            addColoredItem(top, menu, Color.black);

            // Add menu items for this range
            addSetShapes(set, menu, listener);
        }
    }
}
 
Example 2
Source File: ShapeSet.java    From libreveris with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Populate the given menu with a hierarchy of all shapes,
 * organized by defined ShapeSets.
 *
 * @param top      the JComponent to populate (typically a JMenu or a
 *                 JPopupMenu)
 * @param listener the listener for notification of user selection
 */
public static void addAllShapes (JComponent top,
                                 ActionListener listener)
{
    // All ranges of glyph shapes
    for (Field field : ShapeSet.class.getDeclaredFields()) {
        if (field.getType() == ShapeSet.class) {
            ShapeSet set = ShapeSet.valueOf(field.getName());
            JMenu menu = new JMenu(field.getName());

            if (set.rep != null) {
                menu.setIcon(set.rep.getDecoratedSymbol());
            }

            addColoredItem(top, menu, Color.black);

            // Add menu items for this range
            addSetShapes(set, menu, listener);
        }
    }
}
 
Example 3
Source File: ParticleDataTrack.java    From tracker with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a menu with items associated with this track's point properties.
 * 
 * @param trackerPanel the tracker panel
 * @return a menu
 */
protected JMenu getPointMenu(TrackerPanel trackerPanel) {
   // prepare menu items
   colorItem.setText(TrackerRes.getString("TTrack.MenuItem.Color")); //$NON-NLS-1$
   footprintMenu.setText(TrackerRes.getString("TTrack.MenuItem.Footprint")); //$NON-NLS-1$
   velocityMenu.setText(TrackerRes.getString("PointMass.MenuItem.Velocity")); //$NON-NLS-1$
   accelerationMenu.setText(TrackerRes.getString("PointMass.MenuItem.Acceleration")); //$NON-NLS-1$
	JMenu menu = getLeader()!=this? super.getMenu(trackerPanel): new JMenu();
	menu.setText(getPointName());
   menu.setIcon(getFootprint().getIcon(21, 16));
	menu.removeAll();
	menu.add(colorItem);
	menu.add(footprintMenu);
	menu.addSeparator();
	menu.add(velocityMenu);
	menu.add(accelerationMenu);		
   if (trackerPanel.isEnabled("model.stamp")) { //$NON-NLS-1$
		menu.addSeparator();
		menu.add(stampItem);
   }
	return menu;
}
 
Example 4
Source File: MenuEditLayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void configureMenu(final JComponent parent, final JMenu menu) {
    // make sure it will draw it's border so we can have rollovers and selection
    menu.setBorderPainted(true);
    //install the wrapper icon if not a toplevel JMenu
    if(!isTopLevelMenu(menu)) {
        if(!(menu.getIcon() instanceof WrapperIcon)) {
            menu.setIcon(new WrapperIcon(menu.getIcon()));
        }
    }
    
    // configure the maps and popups
    JPopupMenu popup = menu.getPopupMenu();
    menuPopupUIMap.put(menu, popup.getUI());
    popup.setUI(new VisualDesignerPopupMenuUI(this, popup.getUI()));
    
    // get all of the components in this menu
    Component[] subComps = menu.getMenuComponents();
    // if this isn't the first time this menu has been opened then the sub components
    // will have been moved to the popupPanel already, so we will find them there instead.
    JPanel popupPanel = getPopupFactory().containerMap.get(menu);
    if(popupPanel != null) {
        subComps = popupPanel.getComponents();
    }
    
    RADVisualContainer menuRAD = (RADVisualContainer) formDesigner.getMetaComponent(menu);
    registerForm(menuRAD,menu);
    
    // recurse for sub-menus
    for(Component c : subComps) {
        if(c instanceof JMenu) {
            configureMenu(menu, (JMenu)c);
            RADComponent rad = formDesigner.getMetaComponent(c);
            registerForm((RADVisualContainer)rad,(JMenu)c);
        } else {
            configureMenuItem(menu, (JComponent) c);
        }
    }
}
 
Example 5
Source File: JMenuUI.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
public JMenuUI(Program program) {
	super(GuiShared.get().ui(), program);
	setIcon(Images.MISC_EVE.getIcon());

	ListenerClass listener = new ListenerClass();

	jWaypoints = new JMenu(GuiShared.get().uiWaypoint());
	jWaypoints.setIcon(Images.TOOL_ROUTING.getIcon());
	add(jWaypoints);

	jStation = new JMenuItem(GuiShared.get().uiStation());
	jStation.setIcon(Images.LOC_STATION.getIcon());
	jStation.setActionCommand(MenuUIAction.AUTOPILOT_STATION.name());
	jStation.addActionListener(listener);
	jWaypoints.add(jStation);

	jSystem = new JMenuItem(GuiShared.get().uiSystem());
	jSystem.setIcon(Images.LOC_SYSTEM.getIcon());
	jSystem.setActionCommand(MenuUIAction.AUTOPILOT_SYSTEM.name());
	jSystem.addActionListener(listener);
	jWaypoints.add(jSystem);

	jMarket = new JMenuItem(GuiShared.get().uiMarket());
	jMarket.setIcon(Images.TOOL_MARKET_ORDERS.getIcon());
	jMarket.setActionCommand(MenuUIAction.MARKET.name());
	jMarket.addActionListener(listener);
	add(jMarket);

	jOwner = new JMenuItem(GuiShared.get().uiOwner());
	jOwner.setIcon(Images.DIALOG_PROFILES.getIcon());
	jOwner.setActionCommand(MenuUIAction.OWNER.name());
	jOwner.addActionListener(listener);
	add(jOwner);

	jContracts = new JMenuItem(GuiShared.get().uiContract());
	jContracts.setIcon(Images.TOOL_CONTRACTS.getIcon());
	jContracts.setActionCommand(MenuUIAction.CONTRACTS.name());
	jContracts.addActionListener(listener);
	add(jContracts);
}
 
Example 6
Source File: CardSearchPanel.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public void initPopupCollection() throws SQLException {
	JMenu menuItemAdd = new JMenu(MTGControler.getInstance().getLangService().getCapitalize("ADD"));
	menuItemAdd.setIcon(MTGConstants.ICON_NEW);
	for (MagicCollection mc : MTGControler.getInstance().getEnabled(MTGDao.class).listCollections()) {

		JMenuItem adds = new JMenuItem(mc.getName());
		adds.setIcon(MTGConstants.ICON_COLLECTION);
		adds.addActionListener(addEvent -> {

			String collec = ((JMenuItem) addEvent.getSource()).getText();
			lblLoading.start(tableCards.getSelectedRowCount());
			lblLoading.setText(MTGControler.getInstance().getLangService().getCapitalize("ADD_CARDS_TO") + " " + collec);

			for (int i = 0; i < tableCards.getSelectedRowCount(); i++) {

				int viewRow = tableCards.getSelectedRows()[i];
				int modelRow = tableCards.convertRowIndexToModel(viewRow);

				MagicCard mcCard = (MagicCard) tableCards.getModel().getValueAt(modelRow, 0);
				try {
					MTGControler.getInstance().saveCard(mcCard, MTGControler.getInstance().getEnabled(MTGDao.class).getCollection(collec),null);
				} catch (SQLException e1) {
					logger.error(e1);
					MTGControler.getInstance().notify(e1);
				}

			}
			lblLoading.end();
		});
		menuItemAdd.add(adds);
	}

	popupMenu.add(menuItemAdd);
}
 
Example 7
Source File: Utils.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static JPopupMenu makePopUp(
    @Nonnull final PluginContext context,
    final boolean fullScreenModeActive,
    @Nullable final Topic topicUnderMouse
) {
  final JPopupMenu result = UI_COMPO_FACTORY.makePopupMenu();
  final List<PopUpMenuItemPlugin> pluginMenuItems = MindMapPluginRegistry.getInstance().findFor(PopUpMenuItemPlugin.class);
  final List<JMenuItem> tmpList = new ArrayList<JMenuItem>();

  final boolean isModelNotEmpty = context.getPanel().getModel().getRoot() != null;

  putAllItemsAsSection(result, null, findPopupMenuItems(context, PopUpSection.MAIN, fullScreenModeActive, tmpList, topicUnderMouse, pluginMenuItems));
  putAllItemsAsSection(result, null, findPopupMenuItems(context, PopUpSection.MANIPULATORS, fullScreenModeActive, tmpList, topicUnderMouse, pluginMenuItems));
  putAllItemsAsSection(result, null, findPopupMenuItems(context, PopUpSection.EXTRAS, fullScreenModeActive, tmpList, topicUnderMouse, pluginMenuItems));

  final JMenu exportMenu = UI_COMPO_FACTORY.makeMenu(BUNDLE.getString("MMDExporters.SubmenuName"));
  exportMenu.setIcon(ICON_SERVICE.getIconForId(IconID.POPUP_EXPORT));

  final JMenu importMenu = UI_COMPO_FACTORY.makeMenu(BUNDLE.getString("MMDImporters.SubmenuName"));
  importMenu.setIcon(ICON_SERVICE.getIconForId(IconID.POPUP_IMPORT));

  putAllItemsAsSection(result, importMenu, findPopupMenuItems(context, PopUpSection.IMPORT, fullScreenModeActive, tmpList, topicUnderMouse, pluginMenuItems));
  if (isModelNotEmpty) {
    putAllItemsAsSection(result, exportMenu, findPopupMenuItems(context, PopUpSection.EXPORT, fullScreenModeActive, tmpList, topicUnderMouse, pluginMenuItems));
  }

  putAllItemsAsSection(result, null, findPopupMenuItems(context, PopUpSection.TOOLS, fullScreenModeActive, tmpList, topicUnderMouse, pluginMenuItems));
  putAllItemsAsSection(result, null, findPopupMenuItems(context, PopUpSection.MISC, fullScreenModeActive, tmpList, topicUnderMouse, pluginMenuItems));

  return result;
}
 
Example 8
Source File: ContactPopMenu.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
ContactPopMenu(ContactTreeRootNode.ContactInfo contactInfo) {
  this.contactInfo = contactInfo;

  JMenu menuShareProject = new JMenu(Messages.ContactPopMenu_root_popup_text);
  menuShareProject.setIcon(IconManager.SESSIONS_ICON);

  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    menuShareProject.add(createProjectMenu(project));
  }

  add(menuShareProject);
}
 
Example 9
Source File: ClientContextMenu.java    From chipster with MIT License 5 votes vote down vote up
public ClientContextMenu(SwingClientApplication application) {
	this.application = application;

	this.addPopupMenuListener(this);

	visualiseMenuItem = new JMenuItem("Visualise");
	visualiseMenuItem.setFont(this.getFont().deriveFont(Font.BOLD));
	metadataLinkMenu = new JMenu("Link to phenodata");
	metadataLinkMenu.setIcon(VisualConstants.getIcon(VisualConstants.LINK_PHENODATA_MENUICON));
	linksMenu = new JMenu("Links between selected");
	linkToMenu = new JMenu("Link");
	linkToMenu.setIcon(VisualConstants.getIcon(VisualConstants.LINK_MENUICON));
	linksMenu.add(linkToMenu);
	unlinkMenu = new JMenu("Unlink");
	unlinkMenu.setIcon(VisualConstants.getIcon(VisualConstants.UNLINK_MENUICON));
	linksMenu.add(unlinkMenu);

	renameMenuItem = new JMenuItem("Rename");
	deleteMenuItem = new JMenuItem("Delete");
	deleteMenuItem.setIcon(VisualConstants.getIcon(VisualConstants.DELETE_MENUICON));
	importMenuItem = new JMenuItem("Import files...");
	exportMenuItem = new JMenuItem("Export...");
	exportMenuItem.setIcon(VisualConstants.getIcon(VisualConstants.EXPORT_MENUICON));
	historyMenuItem = new JMenuItem("View history as text");
	historyMenuItem.setIcon(VisualConstants.getIcon(VisualConstants.GENERATE_HISTORY_ICON));
	saveWorkflowItem = new JMenuItem("Save workflow");
	
	
	visualiseMenuItem.addActionListener(this);
	renameMenuItem.addActionListener(this);
	deleteMenuItem.addActionListener(this);
	importMenuItem.addActionListener(this);
	exportMenuItem.addActionListener(this);
	historyMenuItem.addActionListener(this);
	saveWorkflowItem.addActionListener(this);

}
 
Example 10
Source File: PageableTable.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Create the right menu bar
 */
private void createMenu() {
	rightMenuBar = new JMenuBar();
	rightMenuBar.setLayout(new BoxLayout(rightMenuBar, BoxLayout.PAGE_AXIS));
	rightMenuBar.setMargin(new Insets(0, 0, 0, 0));
	// Add Visibility menu
	JMenu menu = new JMenu();
	menu.setMargin(new Insets(0,0,0,0));
	menu.setIcon(visibilityMenuIcon);
	menu.setMaximumSize(new Dimension(50,50));
	visibilityBox = new VisibilityBox(columnDescriptors);
	menu.add(visibilityBox);
	menu.getPopupMenu().addPopupMenuListener(new VisibilityPopupListener());
	JMenuItem okMenuItem = new JMenuItem(new OkVisibilityAction());
	JMenuItem cancelMenuItem = new JMenuItem(new CancelVisibilityAction());
	menu.addSeparator();
	menu.add(okMenuItem);
	menu.add(cancelMenuItem);
	rightMenuBar.add(menu);
	JMenu prefsMenu = new JMenu();
	prefsMenu.setMargin(new Insets(0, 0, 0, 0));
	prefsMenu.setIcon(userMenuIcon);
	prefsMenu.setMaximumSize(new Dimension(50,50));
	prefsMenu.add(new JMenuItem(new LoadPreferencesAction(this, 
				messageSource.getMessage("PageableTable.loadPreferences", null, "Load Preferences", Locale.getDefault()))));
	prefsMenu.add(new JMenuItem(new SavePreferencesAction(this, 
				messageSource.getMessage("PageableTable.savePreferences", null, "Save Preferences", Locale.getDefault()))));
	rightMenuBar.add(prefsMenu);
	rightMenuBar.add(Box.createVerticalGlue());
	// Add menu bar to right
	add (rightMenuBar, BorderLayout.EAST);
}
 
Example 11
Source File: BlazeActions.java    From constellation with Apache License 2.0 4 votes vote down vote up
public BlazeActions() {
    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    menuBar = new JMenuBar();
    menuBar.setOpaque(true);

    menu = new JMenu();
    menu.setIcon(ImageUtilities.loadImageIcon(BLAZE_ACTIONS_ICON, false));
    menu.setToolTipText("Blaze Controls");
    menu.addChangeListener(e -> {
        if (graph != null) {
            updateSliders(graph);
        }
    });
    menu.setEnabled(false);

    final JMenuItem selectBlazesItem = new JMenuItem("Select Blazes");
    selectBlazesItem.setIcon(ImageUtilities.loadImageIcon(SELECT_BLAZES_ICON, false));
    selectBlazesItem.setActionCommand(SELECT_BLAZES_ACTION);
    selectBlazesItem.addActionListener(this);
    menu.add(selectBlazesItem);

    final JMenuItem deselectBlazesItem = new JMenuItem("Deselect Blazes");
    deselectBlazesItem.setIcon(ImageUtilities.loadImageIcon(DESELECT_BLAZES_ICON, false));
    deselectBlazesItem.setActionCommand(DESELECT_BLAZES_ACTION);
    deselectBlazesItem.addActionListener(this);
    menu.add(deselectBlazesItem);

    final JMenuItem addBlueBlazeItem = new JMenuItem("Add Blue Blazes");
    addBlueBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_BLUE_BLAZE_ICON, false));
    addBlueBlazeItem.setActionCommand(ADD_BLUE_BLAZE_ACTION);
    addBlueBlazeItem.addActionListener(BlazeActions.this);
    menu.add(addBlueBlazeItem);

    final JMenuItem addRedBlazeItem = new JMenuItem("Add Red Blazes");
    addRedBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_RED_BLAZE_ICON, false));
    addRedBlazeItem.setActionCommand(ADD_RED_BLAZE_ACTION);
    addRedBlazeItem.addActionListener(BlazeActions.this);
    menu.add(addRedBlazeItem);

    final JMenuItem addYellowBlazeItem = new JMenuItem("Add Yellow Blazes");
    addYellowBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_YELLOW_BLAZE_ICON, false));
    addYellowBlazeItem.setActionCommand(ADD_YELLOW_BLAZE_ACTION);
    addYellowBlazeItem.addActionListener(BlazeActions.this);
    menu.add(addYellowBlazeItem);

    final JMenuItem colorBlazeItem = new JMenuItem("Add Custom Blazes");
    colorBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_CUSTOM_BLAZE_ICON, false));
    colorBlazeItem.setActionCommand(ADD_CUSTOM_BLAZE_ACTION);
    colorBlazeItem.addActionListener(BlazeActions.this);
    menu.add(colorBlazeItem);

    final JMenuItem removeBlazeItem = new JMenuItem("Remove Blazes");
    removeBlazeItem.setIcon(ImageUtilities.loadImageIcon(REMOVE_BLAZE_ICON, false));
    removeBlazeItem.setActionCommand(REMOVE_BLAZES_ACTION);
    removeBlazeItem.addActionListener(BlazeActions.this);
    menu.add(removeBlazeItem);

    this.sizeSlider = new SliderMenuItem("Size");
    sizeSlider.setValue((NbPreferences.forModule(GraphPreferenceKeys.class)
            .getInt(GraphPreferenceKeys.BLAZE_SIZE, GraphPreferenceKeys.BLAZE_SIZE_DEFAULT)));
    menu.add(sizeSlider);

    this.opacitySlider = new SliderMenuItem("Opacity");
    opacitySlider.setValue((NbPreferences.forModule(GraphPreferenceKeys.class)
            .getInt(GraphPreferenceKeys.BLAZE_OPACITY, GraphPreferenceKeys.BLAZE_OPACITY_DEFAULT)));
    menu.add(opacitySlider);

    this.sliderChangeListener = e
            -> setBlazeProperties(sizeSlider.getValue() / 100f, opacitySlider.getValue() / 100f);
    sizeSlider.addChangeListener(sliderChangeListener);
    opacitySlider.addChangeListener(sliderChangeListener);

    menuBar.add(menu);
    panel.add(menuBar, BorderLayout.CENTER);

    GraphManager.getDefault().addGraphManagerListener(BlazeActions.this);
}
 
Example 12
Source File: DimActions.java    From constellation with Apache License 2.0 4 votes vote down vote up
public DimActions() {
    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    menuBar = new JMenuBar();
    menuBar.setOpaque(true);

    menu = new JMenu();
    menu.setIcon(ImageUtilities.loadImageIcon(DIM_ACTIONS_ICON, false));
    menu.setToolTipText("Dim Controls");
    menu.setEnabled(false);

    final JMenuItem dimSelectedItem = new JMenuItem("Dim Selected");
    dimSelectedItem.setIcon(ImageUtilities.loadImageIcon(DIM_SELECTED_ICON, false));
    dimSelectedItem.setActionCommand(DIM_SELECTED_ACTION);
    dimSelectedItem.addActionListener(DimActions.this);
    menu.add(dimSelectedItem);

    final JMenuItem dimUnselectedItem = new JMenuItem("Dim Unselected");
    dimUnselectedItem.setIcon(ImageUtilities.loadImageIcon(DIM_UNSELECTED_ICON, false));
    dimUnselectedItem.setActionCommand(DIM_UNSELECTED_ACTION);
    dimUnselectedItem.addActionListener(DimActions.this);
    menu.add(dimUnselectedItem);

    final JMenuItem dimAllItem = new JMenuItem("Dim All");
    dimAllItem.setIcon(ImageUtilities.loadImageIcon(DIM_ALL_ICON, false));
    dimAllItem.setActionCommand(DIM_ALL_ACTION);
    dimAllItem.addActionListener(DimActions.this);
    menu.add(dimAllItem);

    menu.add(new JSeparator(SwingConstants.HORIZONTAL));

    final JMenuItem undimSelectedItem = new JMenuItem("Undim Selected");
    undimSelectedItem.setIcon(ImageUtilities.loadImageIcon(UNDIM_SELECTED_ICON, false));
    undimSelectedItem.setActionCommand(UNDIM_SELECTED_ACTION);
    undimSelectedItem.addActionListener(DimActions.this);
    menu.add(undimSelectedItem);

    final JMenuItem undimUnselectedItem = new JMenuItem("Undim Unselected");
    undimUnselectedItem.setIcon(ImageUtilities.loadImageIcon(UNDIM_UNSELECTED_ICON, false));
    undimUnselectedItem.setActionCommand(UNDIM_UNSELECTED_ACTION);
    undimUnselectedItem.addActionListener(DimActions.this);
    menu.add(undimUnselectedItem);

    final JMenuItem undimAllItem = new JMenuItem("Undim All");
    undimAllItem.setIcon(ImageUtilities.loadImageIcon(UNDIM_ALL_ICON, false));
    undimAllItem.setActionCommand(UNDIM_ALL_ACTION);
    undimAllItem.addActionListener(DimActions.this);
    menu.add(undimAllItem);

    menu.add(new JSeparator(SwingConstants.HORIZONTAL));

    final JMenuItem selectDimmed = new JMenuItem("Select Dimmed");
    selectDimmed.setIcon(ImageUtilities.loadImageIcon(SELECT_DIMMED_ICON, false));
    selectDimmed.setActionCommand(SELECT_DIMMED_ACTION);
    selectDimmed.addActionListener(DimActions.this);
    menu.add(selectDimmed);

    final JMenuItem selectUndimmed = new JMenuItem("Select Undimmed");
    selectUndimmed.setIcon(ImageUtilities.loadImageIcon(SELECT_UNDIMMED_ICON, false));
    selectUndimmed.setActionCommand(SELECT_UNDIMMED_ACTION);
    selectUndimmed.addActionListener(DimActions.this);
    menu.add(selectUndimmed);

    menuBar.add(menu);
    panel.add(menuBar, BorderLayout.CENTER);

    GraphManager.getDefault().addGraphManagerListener(DimActions.this);
}
 
Example 13
Source File: HopActions.java    From constellation with Apache License 2.0 4 votes vote down vote up
public HopActions() {
    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    menuBar = new JMenuBar();
    menuBar.setOpaque(true);

    menu = new JMenu();
    menu.setIcon(HOP_OUT_ONE_ICON);
    menu.setToolTipText("Hop Controls");
    menu.setEnabled(false);

    final JMenuItem hopOutHalfItem = new JMenuItem("Hop Out Half");
    hopOutHalfItem.setIcon(HOP_OUT_HALF_ICON);
    hopOutHalfItem.setActionCommand(HOP_OUT_HALF_ACTION);
    hopOutHalfItem.addActionListener(HopActions.this);
    menu.add(hopOutHalfItem);

    final JMenuItem hopOutOneItem = new JMenuItem("Hop Out One");
    hopOutOneItem.setIcon(HOP_OUT_ONE_ICON);
    hopOutOneItem.setActionCommand(HOP_OUT_ONE_ACTION);
    hopOutOneItem.addActionListener(HopActions.this);
    menu.add(hopOutOneItem);

    final JMenuItem hopOutFullItem = new JMenuItem("Hop Out Full");
    hopOutFullItem.setIcon(HOP_OUT_FULL_ICON);
    hopOutFullItem.setActionCommand(HOP_OUT_FULL_ACTION);
    hopOutFullItem.addActionListener(HopActions.this);
    menu.add(hopOutFullItem);

    final JPanel directionPanel = new JPanel();
    directionPanel.setLayout(new BoxLayout(directionPanel, BoxLayout.Y_AXIS));
    directionPanel.setBorder(new TitledBorder("Direction"));

    outgoing = new JCheckBox("Outgoing", true);
    outgoing.setToolTipText("Hop Along Outgoing Transactions");
    directionPanel.add(outgoing);

    incoming = new JCheckBox("Incoming", true);
    incoming.setToolTipText("Hop Along Incoming Transactions");
    directionPanel.add(incoming);

    undirected = new JCheckBox("Undirected", true);
    undirected.setToolTipText("Hop Along Undirected Transactions");
    directionPanel.add(undirected);

    final JPanel optionsPanel = new JPanel();
    optionsPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
    optionsPanel.setLayout(new BorderLayout());
    optionsPanel.add(directionPanel, BorderLayout.CENTER);

    menu.add(optionsPanel);

    menuBar.add(menu);
    panel.add(menuBar, BorderLayout.CENTER);

    GraphManager.getDefault().addGraphManagerListener(HopActions.this);
}
 
Example 14
Source File: WorkspaceSwitchAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public JMenuItem getMenuPresenter() {
    // beware, we shouldn't cache menu intstance, because getMenuPresenter
    // can be legally called several times and menu component cannot be
    // contained in more than one component hierarchy
    JMenu menu = new org.openide.awt.JMenuPlus();
    Mnemonics.setLocalizedText(menu, getName());
    menu.setHorizontalTextPosition(JMenu.RIGHT);
    menu.setHorizontalAlignment(JMenu.LEFT);
    menu.setIcon(getIcon());
    HelpCtx.setHelpIDString(menu, WorkspaceSwitchAction.class.getName());

    final WindowManager pool = WindowManager.getDefault();

    final Hashtable<ActionListener, Workspace> menu2Workspace = new Hashtable<>(10);

    // ^ maps listener on workspace
    final Hashtable<Workspace, JRadioButtonMenuItem> workspace2Menu = new Hashtable<>(10);

    // ^ maps workspace to menuitem
    final Hashtable<Workspace, ActionListener> workspace2Listener = new Hashtable<>(10);

    // ^ maps workspace to action listener
    final Workspace[] currentDeskRef = new Workspace[1];
    currentDeskRef[0] = pool.getCurrentWorkspace();

    // attach all workspaces
    Workspace[] workspaces = pool.getWorkspaces();

    for (int i = 0; i < workspaces.length; i++) {
        attachWorkspace(workspaces[i], currentDeskRef, workspace2Menu, menu2Workspace, workspace2Listener, menu);
    }

    // check on currently active workspace
    JRadioButtonMenuItem curItem = (JRadioButtonMenuItem) workspace2Menu.get(currentDeskRef[0]);

    if (curItem != null) {
        curItem.setSelected(true);
    }

    // listen to the changes in workspaces
    pool.addPropertyChangeListener(
        getWorkspacePoolListener(workspace2Menu, menu2Workspace, workspace2Listener, currentDeskRef, menu)
    );

    return menu;
}
 
Example 15
Source File: WorkSpaceManager.java    From jeddict with Apache License 2.0 4 votes vote down vote up
public WorkSpaceManager(JPAModelerScene scene) {
    this.scene = scene;
    workSpaceMenu = new JMenu(getMessage(WorkSpaceManager.class, "WorkSpaceManager.workspace"));
    workSpaceMenu.setIcon(WORKSPACE_ICON);
}
 
Example 16
Source File: PerspectiveTrack.java    From tracker with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Prepares menu items and returns a new menu.
 * Subclasses should override this method and add track-specific menu items.
 *
 * @param trackerPanel the tracker panel
 * @return a menu
 */
public JMenu getMenu(TrackerPanel trackerPanel) {
  menu = new JMenu(getName());
  menu.setIcon(getFootprint().getIcon(21, 16));
  return menu;
}