javax.swing.JMenuItem.setEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中javax.swing.JMenuItem.setEnabled()方法的一些代码示例,展示了JMenuItem.setEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.setEnabled()方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:setEnabled

JMenuItem.setEnabled介绍

暂无

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

loadFiles = new JMenuItem("Load trees...");
loadFiles.addActionListener(this);
saveMatches = new JMenuItem("Save matched trees...");
saveMatches.addActionListener(this);
saveMatches.setEnabled(false);
saveSentences = new JMenuItem("Save matched sentences...");
saveSentences.addActionListener(this);
saveSentences.setEnabled(false);
saveHistory = new JMenuItem("Save statistics...");
saveHistory.addActionListener(this);
saveHistory.setEnabled(false);
loadTsurgeon = new JMenuItem("Load Tsurgeon script...");
loadTsurgeon.addActionListener(this);
clearFileList = new JMenuItem("Clear tree file list");
clearFileList.addActionListener(this);
clearFileList.setEnabled(false);
quit = new JMenuItem("Exit");
quit.addActionListener(this);

代码示例来源:origin: redwarp/9-Patch-Resizer

private void setMenuBar() {
 JMenuBar menuBar = new JMenuBar();
 this.setJMenuBar(menuBar);
 JMenu mnEdit = new JMenu(Localization.get("menu_edit"));
 menuBar.add(mnEdit);
 this.mntmClear = new JMenuItem(Localization.get("menu_item_clear"));
 this.mntmClear.setAction(this.action);
 this.mntmClear.setEnabled(false);
 mnEdit.add(this.mntmClear);
 JMenu mnHelp = new JMenu(Localization.get("menu_help"));
 menuBar.add(mnHelp);
 JMenuItem mntmAbout = new JMenuItem();
 mntmAbout.setAction(new AboutAction());
 mnHelp.add(mntmAbout);
}

代码示例来源:origin: winder/Universal-G-Code-Sender

private void initComponents() {
  startServer.addActionListener(evt -> startPendantServerButtonActionPerformed());
  stopServer.addActionListener(evt -> stopPendantServerButtonActionPerformed());
  stopServer.setEnabled(false);
  add(startServer);
  add(stopServer);
}

代码示例来源:origin: deathmarine/Luyten

public void updateRecentFiles() {
  if (RecentFiles.paths.isEmpty()) {
    recentFiles.setEnabled(false);
    clearRecentFiles.setEnabled(false);
    return;
  } else {
    recentFiles.setEnabled(true);
    clearRecentFiles.setEnabled(true);
    JMenuItem menuItem = new JMenuItem(path);
    menuItem.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {

代码示例来源:origin: apache/pdfbox

private JMenu createEditMenu()
{
  JMenu editMenu = new JMenu("Edit");
  editMenu.setMnemonic('E');
  
  JMenuItem cutMenuItem = new JMenuItem("Cut");
  cutMenuItem.setEnabled(false);
  editMenu.add(cutMenuItem);
  JMenuItem copyMenuItem = new JMenuItem("Copy");
  copyMenuItem.setEnabled(false);
  editMenu.add(copyMenuItem);
  JMenuItem pasteMenuItem = new JMenuItem("Paste");
  pasteMenuItem.setEnabled(false);
  editMenu.add(pasteMenuItem);
  JMenuItem deleteMenuItem = new JMenuItem("Delete");
  deleteMenuItem.setEnabled(false);
  editMenu.add(deleteMenuItem);
  editMenu.addSeparator();
  editMenu.add(createFindMenu());
  
  return editMenu;
}

代码示例来源:origin: apache/pdfbox

@Override
public void ancestorAdded(AncestorEvent ancestorEvent)
{
  zoomMenu.addMenuListeners(this);
  zoomMenu.setEnableMenu(true);
  
  rotationMenu = RotationMenu.getInstance();
  rotationMenu.addMenuListeners(this);
  rotationMenu.setEnableMenu(true);
  
  viewMenu = ViewMenu.getInstance(null);
  JMenu menuInstance = viewMenu.getMenu();
  int itemCount = menuInstance.getItemCount();
  
  for (int i = 0; i< itemCount; i++)
  {
    JMenuItem item = menuInstance.getItem(i);
    if (item != null)
    {
      item.setEnabled(true);
      item.addActionListener(this);
    }
  }
}

代码示例来源:origin: stanfordnlp/CoreNLP

JMenuItem openFile = new JMenuItem("Open File");
openFile.setMnemonic('O');
openFile.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, menuMask));
openFile.addActionListener(actor);
fileMenu.add(openFile);
JMenuItem loadURL = new JMenuItem("Load URL");
loadURL.setMnemonic('L');
loadURL.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, menuMask));
loadURL.addActionListener(actor);
fileMenu.add(loadURL);
saveUntagged = new JMenuItem("Save Untagged File");
saveUntagged.setMnemonic('S');
saveUntagged.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, menuMask));
saveUntagged.addActionListener(actor);
saveUntagged.setEnabled(false);
fileMenu.add(saveUntagged);
saveTaggedAs.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, menuMask));
saveTaggedAs.addActionListener(actor);
saveTaggedAs.setEnabled(false);
fileMenu.add(saveTaggedAs);

代码示例来源:origin: org.netbeans.api/org-openide-explorer

/** Helper method. Creates empty menu item. */
private static JMenuItem createEmptyMenuItem() {
  JMenuItem empty = new JMenuItem(NbBundle.getMessage(MenuView.class, "EmptySubMenu"));
  empty.setEnabled(false);
  return empty;
}

代码示例来源:origin: ron190/jsql-injection

public void initErrorMethods(Vendor vendor) {
  this.itemRadioStrategyError[0].removeAll();
  Integer[] i = { 0 };
  if (vendor != Vendor.AUTO && vendor.instance().getXmlModel().getStrategy().getError() != null) {
    for (Method methodError: vendor.instance().getXmlModel().getStrategy().getError().getMethod()) {
      JMenuItem itemRadioVendor = new JRadioButtonMenuItem(methodError.getName());
      itemRadioVendor.setEnabled(false);
      this.itemRadioStrategyError[0].add(itemRadioVendor);
      this.groupStrategy.add(itemRadioVendor);
      final int indexError = i[0];
      itemRadioVendor.addActionListener(actionEvent -> {
        ManagerDatabase.this.menuStrategy.setText(methodError.getName());
        MediatorModel.model().setStrategy(StrategyInjection.ERROR);
        ((StrategyInjectionError) StrategyInjection.ERROR.instance()).setIndexMethod(indexError);
      });
      i[0]++;
    }
  }
}

代码示例来源:origin: stanfordnlp/CoreNLP

JMenuItem openFile = new JMenuItem("Open File");
openFile.setMnemonic('O');
openFile.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, shortcutMask));
openFile.addActionListener(actor);
fileMenu.add(openFile);
JMenuItem loadURL = new JMenuItem("Load URL");
loadURL.setMnemonic('L');
loadURL.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, shortcutMask));
loadURL.addActionListener(actor);
fileMenu.add(loadURL);
saveUntagged = new JMenuItem("Save Untagged File");
saveUntagged.setMnemonic('S');
saveUntagged.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, shortcutMask));
saveUntagged.addActionListener(actor);
saveUntagged.setEnabled(false);
fileMenu.add(saveUntagged);
saveTaggedAs.setAccelerator(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, shortcutMask));
saveTaggedAs.addActionListener(actor);
saveTaggedAs.setEnabled(false);
fileMenu.add(saveTaggedAs);

代码示例来源:origin: org.apache.river.examples/browser

private static void addNone(JMenu menu) {
JMenuItem item = new JMenuItem("(none)");
item.setEnabled(false);
menu.add(item);
}

代码示例来源:origin: raydac/netbeans-mmd-plugin

@Override
@Nullable
public JMenuItem makeMenuItem(@Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics, @Nullable final CustomJob customProcessor) {
 final JMenuItem result = UI_COMPO_FACTORY.makeMenuItem(Texts.getString("MMDGraphEditor.makePopUp.miCollapseAll"), ICO);
 result.setEnabled(panel.getModel().getRoot() != null);
 result.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(@Nonnull final ActionEvent e) {
   panel.collapseOrExpandAll(true);
  }
 });
 return result;
}

代码示例来源:origin: deathmarine/Luyten

private void buildEditMenu(JMenu editMenu) {
  editMenu.removeAll();
  JMenuItem menuItem = new JMenuItem("Cut");
  menuItem.setAccelerator(
      KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
  menuItem.setEnabled(false);
  editMenu.add(menuItem);
  menuItem = new JMenuItem("Copy");
  menuItem.addActionListener(new DefaultEditorKit.CopyAction());
  menuItem.setAccelerator(
      KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
  editMenu.add(menuItem);
  menuItem = new JMenuItem("Paste");
  menuItem.setAccelerator(
      KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
  menuItem.setEnabled(false);
  editMenu.add(menuItem);
  menuItem.setAccelerator(
      KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
  menuItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Helper method. Creates empty menu item. */
private static JMenuItem createEmptyMenuItem() {
  JMenuItem empty = new JMenuItem(
    NbBundle.getMessage(MenuView.class, "EmptySubMenu")
  );
  empty.setEnabled(false);
  return empty;
}

代码示例来源:origin: raydac/netbeans-mmd-plugin

@Override
@Nullable
public JMenuItem makeMenuItem(@Nonnull final MindMapPanel panel, @Nonnull final DialogProvider dialogProvider, @Nullable final Topic topic, @Nonnull @MustNotContainNull final Topic[] selectedTopics, @Nullable final CustomJob customProcessor) {
 final JMenuItem result = UI_COMPO_FACTORY.makeMenuItem(Texts.getString("MMDGraphEditor.makePopUp.miExpandAll"), ICO);
 result.setEnabled(panel.getModel().getRoot() != null);
 result.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(@Nonnull final ActionEvent e) {
   panel.collapseOrExpandAll(false);
  }
 });
 return result;
}

代码示例来源:origin: 4thline/cling

for (int i = 0; i < SUPPORTED_INSTANCES; i++) {
    final int instanceId = i;
    JMenuItem instanceItem = new JMenuItem("Instance: " + i);
    instanceItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        presenter.onSendToMediaRenderer(
  menuItem = new JMenuItem(
      entry.getKey().getDetails().getFriendlyName() + " (Not Compatible)"
  );
  menuItem.setEnabled(false);
JMenuItem noRenderersItem = new JMenuItem("No MediaRenderers found...");
noRenderersItem.setEnabled(false);
menuItems.add(noRenderersItem);

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Helper method. Creates empty menu item. */
private static JMenuItem createEmptyMenuItem() {
  JMenuItem empty = new JMenuItem(
    NbBundle.getMessage(MenuView.class, "EmptySubMenu")
  );
  empty.setEnabled(false);
  return empty;
}

代码示例来源:origin: omegat-org/omegat

private void setQuickScriptMenu(ScriptItem scriptItem, int index) {
  m_quickScripts[index] = scriptItem.getFile().getName();
  removeAllQuickScriptActionListenersFrom(m_quickMenus[index]);
  m_quickMenus[index].addActionListener(new QuickScriptActionListener(index));
  // Since the script is run while editing a segment, the shortcut should not interfere
  // with the segment content, so we set it to a Function key.
  m_quickMenus[index].setAccelerator(KeyStroke.getKeyStroke("shift ctrl F" + (index + 1)));
  m_quickMenus[index].setEnabled(true);
  if ("".equals(scriptItem.getDescription())) {
    m_quickMenus[index].setToolTipText(scriptItem.getDescription());
  }
  Mnemonics.setLocalizedText(m_quickMenus[index], "&" + scriptKey(index) + " - " + scriptItem.getScriptName());
}

代码示例来源:origin: cmusphinx/sphinx4

menuBar.add(menu);
JMenuItem menuItem = new JMenuItem("Open...");
menuItem.setAccelerator(KeyStroke.getKeyStroke("control O"));
menuItem.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    getFilename("Open...", JFileChooser.OPEN_DIALOG);
menu.add(menuItem);
saveMenuItem = new JMenuItem("Save");
saveMenuItem.setAccelerator(KeyStroke.getKeyStroke("control S"));
saveMenuItem.setEnabled(false);
saveMenuItem.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    if (filename != null && !filename.isEmpty()) {
menu.add(saveMenuItem);
menuItem = new JMenuItem("Save As...");
menuItem.setAccelerator(KeyStroke.getKeyStroke("control V"));
menuItem.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    getFilename("Save As...", JFileChooser.SAVE_DIALOG);

代码示例来源:origin: RPTools/maptool

protected void addOwnedItem(Action action) {
  if (action == null) {
    return;
  }
  JMenuItem item = new JMenuItem(action);
  item.setEnabled(areTokensOwned);
  add(new JMenuItem(action));
}

相关文章

JMenuItem类方法