本文整理汇总了Java中javax.swing.event.MenuEvent类的典型用法代码示例。如果您正苦于以下问题:Java MenuEvent类的具体用法?Java MenuEvent怎么用?Java MenuEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MenuEvent类属于javax.swing.event包,在下文中一共展示了MenuEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
@Override
public void menuSelected (MenuEvent e)
{
SheetStub stub = StubsController.getCurrentStub();
boolean isIdle = (stub != null) && (stub.getCurrentStep() == null);
for (int i = 0; i < menu.getItemCount(); i++) {
JMenuItem menuItem = menu.getItem(i);
// Adjust the status for each step
if (menuItem instanceof StepItem) {
StepItem item = (StepItem) menuItem;
item.displayState(stub, isIdle);
}
}
}
示例2: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
/**
* check file menu
*/
public void menuSelected(MenuEvent e) {
JMenu source = (JMenu) e.getSource();
if((source != null) && "File".equals(source.getText())) {
// close menu item only active, if something is selected.
getMainMenu().getCloseMenuItem().setEnabled(tree.getSelectionPath() != null);
getMainMenu().getCloseToolBarButton().setEnabled(tree.getSelectionPath() != null);
}
}
示例3: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
/** MenuListener method overriding. */
@Override
public final void menuSelected(MenuEvent event) {
MainDesktopPane desktop = mainWindow.getDesktop();
marsNavigatorItem.setSelected(desktop.isToolWindowOpen(NavigatorWindow.NAME));
searchToolItem.setSelected(desktop.isToolWindowOpen(SearchWindow.NAME));
timeToolItem.setSelected(desktop.isToolWindowOpen(TimeWindow.NAME));
monitorToolItem.setSelected(desktop.isToolWindowOpen(MonitorWindow.NAME));
missionToolItem.setSelected(desktop.isToolWindowOpen(MissionWindow.NAME));
settlementToolItem.setSelected(desktop.isToolWindowOpen(SettlementWindow.NAME));
scienceToolItem.setSelected(desktop.isToolWindowOpen(ScienceWindow.NAME));
resupplyToolItem.setSelected(desktop.isToolWindowOpen(ResupplyWindow.NAME));
//marsViewerItem.setSelected(desktop.isToolWindowOpen(MarsViewer.NAME));
showUnitBarItem.setSelected(desktop.getMainWindow().getUnitToolBar().isVisible());
showToolBarItem.setSelected(desktop.getMainWindow().getToolToolBar().isVisible());
musicVolumeItem.setValue(Math.round(desktop.getSoundPlayer().getMusicVolume() * 10F));
musicVolumeItem.setEnabled(!desktop.getSoundPlayer().isMusicMute());
effectVolumeItem.setValue(Math.round(desktop.getSoundPlayer().getEffectVolume() * 10F));
effectVolumeItem.setEnabled(!desktop.getSoundPlayer().isSoundMute());
musicMuteItem.setSelected(desktop.getSoundPlayer().isMusicMute());
effectMuteItem.setSelected(desktop.getSoundPlayer().isSoundMute());
}
示例4: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
public void menuSelected(MenuEvent event) {
// Remove all previous items
while (getItemCount() > 2)
remove(2);
int windowsAdded = 0;
// Create a menu item for each window
for (Frame window : Frame.getFrames()) {
if (window.isVisible()) {
FrameMenuItem newItem = new FrameMenuItem(window, this);
add(newItem);
windowsAdded++;
}
}
// Disable the Close all button if we only have the main window
closeAllMenuItem.setEnabled(windowsAdded > 1);
}
示例5: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
/**
* Populate the sub-menus if needed.
* ${@inheritDoc}.
*/
public void menuSelected(final MenuEvent arg0) {
if (getSubElements().length > 0) {
return;
}
synchronized (this) {
if (loadSubMenus == null) {
loadSubMenus = new SubMenuLoader(false);
Future<?> submited = SUBMENULOADEREXECUTOR.submit(loadSubMenus);
this.loadSubMenusFuture = submited;
add(isLoadingMenuItem);
}
}
}
示例6: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
public void menuSelected(MenuEvent e) {
TabsMenu.this.removeAll();
ExploreNodeAction exploreAction = new ExploreNodeAction(cliGuiCtx);
JMenuItem exploreSelectedNode = new JMenuItem(exploreAction);
exploreSelectedNode.setMnemonic(KeyEvent.VK_E);
if ((exploreAction.getSelectedNode() == null) || exploreAction.getSelectedNode().isLeaf()) {
exploreSelectedNode.setEnabled(false);
}
add(exploreSelectedNode);
addSeparator();
JTabbedPane tabs = cliGuiCtx.getTabs();
for (int i=0; i < tabs.getTabCount(); i++) {
GoToTabAction action = new GoToTabAction(i, tabs.getTitleAt(i));
JMenuItem item = new JMenuItem(action);
item.setToolTipText(tabs.getToolTipTextAt(i));
add(item);
}
}
示例7: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
@Override
public void menuSelected (MenuEvent e)
{
Sheet sheet = SheetsController.getCurrentSheet();
boolean isIdle = (sheet != null)
&& (sheet.getCurrentStep() == null);
for (int i = 0; i < menu.getItemCount(); i++) {
JMenuItem menuItem = menu.getItem(i);
// Adjust the status for each step
if (menuItem instanceof StepItem) {
StepItem item = (StepItem) menuItem;
item.displayState(sheet, isIdle);
}
}
}
示例8: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
public void menuSelected(MenuEvent ev) {
Object[] values;
try {
values = lookup.getFieldValues(tmpl, index, field.getName());
} catch (Throwable t) {
failure(t);
return;
}
if (values == null) {
addNone(menu);
return;
}
for (int i = 0; i < values.length; i++) {
JMenuItem item = new JMenuItem(values[i].toString());
item.addActionListener(
wrap(new Value(index, field, values[i])));
menu.add(item);
}
}
示例9: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
@Override
public void menuSelected(MenuEvent e) {
if (menu.getItemCount() > 0) {
// already built before
return;
}
Set<Figure> set = figure.getPredecessorSet();
if (successors) {
set = figure.getSuccessorSet();
}
boolean first = true;
for (Figure f : set) {
if (f == figure) {
continue;
}
if (first) {
first = false;
} else {
menu.addSeparator();
}
Action go = diagramScene.createGotoAction(f);
menu.add(go);
JMenu preds = new JMenu("Nodes Above");
preds.addMenuListener(new NeighborMenuListener(preds, f, false));
menu.add(preds);
JMenu succs = new JMenu("Nodes Below");
succs.addMenuListener(new NeighborMenuListener(succs, f, true));
menu.add(succs);
}
if (menu.getItemCount() == 0) {
menu.add("(none)");
}
}
示例10: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
@Override
public void menuSelected(MenuEvent e) {
if (menu.getItemCount() > 0) {
// already built before
return;
}
build(menu.getPopupMenu(), figure, FigureWidget.this, successors, diagramScene);
}
示例11: menuDeselected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
public void menuDeselected(MenuEvent e) {
JMenu wm = (JMenu) e.getSource();
// Cleans Windows if not visible
if(wm.getText().matches("Windows") || wm.getText().matches("Window")) {
wm.removeAll();
System.gc();
}
/* When user first imports menu item the background is set to another color to catch user attention.
* After user interaction will set the background color back.
*/
if(wm.getText().matches("My Layer Sessions")) {
JMenu selectSessionMenu = (JMenu) wm;
try {
JMenuItem selectSessionMenuChild = (JMenuItem) selectSessionMenu.getMenuComponent(0);
Color currentColor = selectSessionMenu.getBackground();
Color defaultColor = selectSessionMenuChild.getBackground();
if(currentColor.getRed() + currentColor.getGreen() + currentColor.getBlue() == 586) {
selectSessionMenu.setBackground(defaultColor);
selectSessionMenu.revalidate();
}
} catch (Exception ex) {
//don't do anything if menu component and cannot be cast as a JMenuItem
//(eg if it is a separator bar)
}
}
}
示例12: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
@Override
public void menuSelected (MenuEvent e)
{
boolean enabled = StubsController.getCurrentStub() != null;
for (int i = 0; i < menu.getItemCount(); i++) {
JMenuItem menuItem = menu.getItem(i);
// Beware of separators (for which returned menuItem is null)
if (menuItem != null) {
menuItem.setEnabled(enabled);
}
}
}
示例13: menuSelected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
@Override
public void menuSelected (MenuEvent e)
{
// Clean up the whole menu
menu.removeAll();
// Rebuild the whole list of menu items on the fly
buildItems();
}
示例14: feedMenu
import javax.swing.event.MenuEvent; //导入依赖的package包/类
/**
* Feed a menu with the dynamic content of this NameSet.
*
* @param menu the menu to be fed, if null it is allocated by this method
* @param itemListener the listener to be called on item selection
* @return the menu properly dynamized
*/
public JMenu feedMenu (JMenu menu,
final ActionListener itemListener)
{
final JMenu finalMenu = (menu != null) ? menu : new JMenu(setName);
MenuListener menuListener = new AbstractMenuListener()
{
@Override
public void menuSelected (MenuEvent e)
{
// Clean up the whole menu
finalMenu.removeAll();
// Rebuild the whole list of menu items on the fly
synchronized (NameSet.this) {
for (String f : names) {
JMenuItem menuItem = new JMenuItem(f);
menuItem.addActionListener(itemListener);
finalMenu.add(menuItem);
}
}
}
};
// Listener to menu selection, to modify content on-the-fly
finalMenu.addMenuListener(menuListener);
return finalMenu;
}
示例15: menuDeselected
import javax.swing.event.MenuEvent; //导入依赖的package包/类
/**
* This method is called when menu is deselected. It clears selected index
* in the selectionModel of the menu parent.
*
* @param e The MenuEvent.
*/
public void menuDeselected(MenuEvent e)
{
JMenu menu = (JMenu) menuItem;
if (menu.getParent() != null)
{
if (menu.isTopLevelMenu())
((JMenuBar) menu.getParent()).getSelectionModel().clearSelection();
else
((JPopupMenu) menu.getParent()).getSelectionModel().clearSelection();
}
}