Java Code Examples for com.alee.laf.menu.WebPopupMenu#pack()
The following examples show how to use
com.alee.laf.menu.WebPopupMenu#pack() .
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: 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 2
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(); }