Java Code Examples for com.alee.laf.menu.WebPopupMenu#add()
The following examples show how to use
com.alee.laf.menu.WebPopupMenu#add() .
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: Utils.java From desktopclient-java with GNU General Public License v3.0 | 6 votes |
static WebPopupMenu createCopyMenu(boolean modifiable) { WebPopupMenu menu = new WebPopupMenu(); if (modifiable) { Action cut = new DefaultEditorKit.CutAction(); cut.putValue(Action.NAME, Tr.tr("Cut")); cut.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control X")); menu.add(cut); } Action copy = new DefaultEditorKit.CopyAction(); copy.putValue(Action.NAME, Tr.tr("Copy")); copy.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control C")); menu.add(copy); if (modifiable) { Action paste = new DefaultEditorKit.PasteAction(); paste.putValue(Action.NAME, Tr.tr("Paste")); paste.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control V")); menu.add(paste); } return menu; }
Example 2
Source File: NavigatorWindow.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** * Creates the minerals menu. */ private WebPopupMenu createMineralsMenu() { // Create the mineral options menu. WebPopupMenu mineralsMenu = new WebPopupMenu(); // Create each mineral check box item. MineralMapLayer mineralMapLayer = (MineralMapLayer) mineralLayer; java.util.Map<String, Color> mineralColors = mineralMapLayer.getMineralColors(); Iterator<String> i = mineralColors.keySet().iterator(); while (i.hasNext()) { String mineralName = i.next(); Color mineralColor = mineralColors.get(mineralName); boolean isMineralDisplayed = mineralMapLayer.isMineralDisplayed(mineralName); WebCheckBoxMenuItem mineralItem = new WebCheckBoxMenuItem(mineralName, isMineralDisplayed); mineralItem.setIcon(createColorLegendIcon(mineralColor, mineralItem)); mineralItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SwingUtilities.invokeLater(() -> { WebCheckBoxMenuItem checkboxItem = (WebCheckBoxMenuItem) event.getSource(); ((MineralMapLayer) mineralLayer).setMineralDisplayed(checkboxItem.getText(), checkboxItem.isSelected()); }); } }); mineralsMenu.add(mineralItem); } mineralsMenu.pack(); return mineralsMenu; }
Example 3
Source File: ComponentUtils.java From desktopclient-java with GNU General Public License v3.0 | 5 votes |
@Override public JPopupMenu getComponentPopupMenu() { WebPopupMenu menu = new WebPopupMenu(); if (mFile == null) return null; // should never happen WebMenuItem saveMenuItem = new WebMenuItem(Tr.tr("Save File As…")); saveMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (mFile == null) return; // should never happen File suggestedFile = new File( mFileChooser.getCurrentDirectory(), mFile.getName()); mFileChooser.setSelectedFile(suggestedFile); // fix WebLaf bug mFileChooser.getFileChooserPanel().setSelectedFiles(new File[]{suggestedFile}); int option = mFileChooser.showSaveDialog(AttachmentPanel.this); if (option == JFileChooser.APPROVE_OPTION) { try { Files.copy(mFile.toPath(), mFileChooser.getSelectedFile().toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (IOException ex) { LOGGER.log(Level.WARNING, "can't copy file", ex); } } } }); if (!mFile.exists()) { saveMenuItem.setEnabled(false); saveMenuItem.setToolTipText(Tr.tr("File does not exist")); } menu.add(saveMenuItem); return menu; }
Example 4
Source File: ComponentUtils.java From desktopclient-java with GNU General Public License v3.0 | 5 votes |
private void showPopupMenu(MouseEvent e) { WebPopupMenu menu = new WebPopupMenu(); WebMenuItem removeItem = new WebMenuItem(Tr.tr("Remove")); removeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { EditableAvatarImage.this.changeImage(null); } }); removeItem.setEnabled(EditableAvatarImage.this.canRemove()); menu.add(removeItem); menu.show(this, e.getX(), e.getY()); }
Example 5
Source File: NavigatorWindow.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Create the map options menu. */ private void createOptionsMenu() { // Create options menu. optionsMenu = new WebPopupMenu(); optionsMenu.setToolTipText(Msg.getString("NavigatorWindow.menu.mapOptions")); //$NON-NLS-1$ // Create day/night tracking menu item. dayNightItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.daylightTracking"), //$NON-NLS-1$ mapLayerPanel.hasMapLayer(shadingLayer)); dayNightItem.addActionListener(this); optionsMenu.add(dayNightItem); // Unchecked dayNightItem at the start of sim // globeNav.setDayNightTracking(false); dayNightItem.setSelected(false); // Create topographical map menu item. surfItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.surf"), //$NON-NLS-1$ SurfMarsMap.TYPE.equals(mapLayerPanel.getMapType())); surfItem.addActionListener(this); optionsMenu.add(surfItem); // Create topographical map menu item. topoItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.topo"), //$NON-NLS-1$ TopoMarsMap.TYPE.equals(mapLayerPanel.getMapType())); topoItem.addActionListener(this); optionsMenu.add(topoItem); // Create topographical map menu item. geoItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.geo"), //$NON-NLS-1$ GeologyMarsMap.TYPE.equals(mapLayerPanel.getMapType())); geoItem.addActionListener(this); optionsMenu.add(geoItem); ButtonGroup group = new ButtonGroup(); group.add(surfItem); group.add(topoItem); group.add(geoItem); // JMenuItem mapItem = new JMenuItem(Msg.getString("NavigatorWindow.menu.selectMap"));//, KeyEvent.VK_M); // mapItem.add(geoItem); // mapItem.add(surfItem); // mapItem.add(geoItem); // optionsMenu.add(mapItem); // Create unit label menu item. unitLabelItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.showLabels"), //$NON-NLS-1$ mapLayerPanel.hasMapLayer(unitLabelLayer)); unitLabelItem.addActionListener(this); optionsMenu.add(unitLabelItem); // Create vehicle trails menu item. trailItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.showVehicleTrails"), //$NON-NLS-1$ mapLayerPanel.hasMapLayer(trailLayer)); trailItem.addActionListener(this); optionsMenu.add(trailItem); // Create landmarks menu item. landmarkItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.showLandmarks"), //$NON-NLS-1$ mapLayerPanel.hasMapLayer(landmarkLayer)); landmarkItem.addActionListener(this); optionsMenu.add(landmarkItem); // Create navpoints menu item. navpointItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.showNavPoints"), //$NON-NLS-1$ mapLayerPanel.hasMapLayer(navpointLayer)); navpointItem.addActionListener(this); optionsMenu.add(navpointItem); // Create explored site menu item. exploredSiteItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.showExploredSites"), //$NON-NLS-1$ mapLayerPanel.hasMapLayer(exploredSiteLayer)); exploredSiteItem.addActionListener(this); optionsMenu.add(exploredSiteItem); // Create minerals menu item. mineralItem = new WebCheckBoxMenuItem(Msg.getString("NavigatorWindow.menu.map.showMinerals"), //$NON-NLS-1$ mapLayerPanel.hasMapLayer(mineralLayer)); mineralItem.addActionListener(this); optionsMenu.add(mineralItem); optionsMenu.pack(); }
Example 6
Source File: TabMenuButton.java From weblaf with GNU General Public License v3.0 | 4 votes |
@Override public void actionPerformed ( @NotNull final ActionEvent e ) { // Creating menu to show final WebPopupMenu menu = new WebPopupMenu ( StyleId.tabbedpaneTabMenu.at ( this ) ); final ButtonGroup group = new ButtonGroup (); for ( int tabIndex = 0; tabIndex < tabbedPane.getTabCount (); tabIndex++ ) { final TabMenuItem menuItem = new TabMenuItem ( tabbedPane, menu, tabIndex ); menu.add ( menuItem ); group.add ( menuItem ); } // Positioning it according to tab placement final boolean ltr = tabbedPane.getComponentOrientation ().isLeftToRight (); final Dimension menuSize = menu.getPreferredSize (); if ( tabbedPane.getTabPlacement () == JTabbedPane.TOP ) { menu.show ( this, ltr ? getWidth () - menuSize.width : 0, getHeight () ); } else if ( tabbedPane.getTabPlacement () == JTabbedPane.BOTTOM ) { menu.show ( this, ltr ? getWidth () - menuSize.width : 0, -menuSize.height ); } else if ( ltr && tabbedPane.getTabPlacement () == JTabbedPane.LEFT || !ltr && tabbedPane.getTabPlacement () == JTabbedPane.RIGHT ) { menu.show ( this, getWidth (), getHeight () - menuSize.height ); } else if ( ltr && tabbedPane.getTabPlacement () == JTabbedPane.RIGHT || !ltr && tabbedPane.getTabPlacement () == JTabbedPane.LEFT ) { menu.show ( this, -menuSize.width, getHeight () - menuSize.height ); } }