java.awt.MenuItem.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(137)

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

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

private MenuBar createMenuBar() {
  MenuBar ret=new MenuBar();
  Menu file=new Menu("File");
  MenuItem quitm=new MenuItem("Quit");
  ret.setFont(def_font2);
  ret.add(file);
  file.addSeparator();
  file.add(quitm);
  quitm.addActionListener(e -> System.exit(1));
  return ret;
}

代码示例来源:origin: igniterealtime/Openfire

final MenuItem showMenuItem = new MenuItem("Hide");
showMenuItem.setActionCommand("Hide/Show");
menu.add(showMenuItem);
final MenuItem startMenuItem = new MenuItem("Start");
startMenuItem.setActionCommand("Start");
menu.add(startMenuItem);
final MenuItem stopMenuItem = new MenuItem("Stop");
stopMenuItem.setActionCommand("Stop");
menu.add(stopMenuItem);
final MenuItem browserMenuItem = new MenuItem("Launch Admin");
browserMenuItem.setActionCommand("Launch Admin");
menu.add(browserMenuItem);
final MenuItem quitMenuItem = new MenuItem("Quit");
quitMenuItem.setActionCommand("Quit");
menu.add(quitMenuItem);

代码示例来源:origin: stackoverflow.com

MenuItem runWait = new MenuItem("wait", 1, 1) {
  public void run() {
    UiApplication.getUiApplication().invokeLater(

代码示例来源:origin: RipMeApp/ripme

});
PopupMenu trayMenu = new PopupMenu();
trayMenuMain = new MenuItem("Hide");
trayMenuMain.addActionListener(arg0 -> toggleTrayClick());
MenuItem trayMenuAbout = new MenuItem("About " + mainFrame.getTitle());
trayMenuAbout.addActionListener(arg0 -> {
  StringBuilder about = new StringBuilder();
MenuItem trayMenuExit = new MenuItem("Exit");
trayMenuExit.addActionListener(arg0 -> System.exit(0));
trayMenuAutorip = new CheckboxMenuItem("Clipboard Autorip");

代码示例来源:origin: stackoverflow.com

MenuItem defaultItem = new MenuItem(...);
defaultItem.addActionListener(listener);
popup.add(defaultItem);

代码示例来源:origin: stackoverflow.com

MenuItem defaultItem=new MenuItem("Exit");
defaultItem.addActionListener(exitListener);
popup.add(defaultItem);
defaultItem=new MenuItem("Open");
defaultItem.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {

代码示例来源:origin: com.h2database/h2

MenuItem itemConsole = new MenuItem("H2 Console");
itemConsole.setActionCommand("console");
itemConsole.addActionListener(this);
itemConsole.setFont(font);
menuConsole.add(itemConsole);
MenuItem itemStatus = new MenuItem("Status");
itemStatus.setActionCommand("status");
itemStatus.addActionListener(this);
itemStatus.setFont(font);
menuConsole.add(itemStatus);
MenuItem itemExit = new MenuItem("Exit");
itemExit.setFont(font);
itemExit.setActionCommand("exit");

代码示例来源:origin: stackoverflow.com

MenuItem showItem = new MenuItem("Show");
showItem.addActionListener(showListener);
popup.add(showItem);
MenuItem closeItem = new MenuItem("Close");
closeItem.addActionListener(closeListener);
popup.add(closeItem);

代码示例来源:origin: stackoverflow.com

MenuItem exitMenuItem = new MenuItem("E_xit");
exitMenuItem.setGraphic(new ImageView(new Image(CLOSE_ICON)));
exitMenuItem.setOnAction(new EventHandler<ActionEvent>() {
fileMenu.getItems().setAll(exitMenuItem);
Menu zoomMenu = new Menu("_Zoom");
MenuItem zoomResetMenuItem = new MenuItem("Zoom _Reset");
zoomResetMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.ESCAPE));
zoomResetMenuItem.setGraphic(new ImageView(new Image(ZOOM_RESET_ICON)));
MenuItem zoomInMenuItem = new MenuItem("Zoom _In");
zoomInMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.I));
zoomInMenuItem.setGraphic(new ImageView(new Image(ZOOM_IN_ICON)));
MenuItem zoomOutMenuItem = new MenuItem("Zoom _Out");
zoomOutMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.O));
zoomOutMenuItem.setGraphic(new ImageView(new Image(ZOOM_OUT_ICON)));

代码示例来源:origin: stackoverflow.com

MenuItem exitMenuItem = new MenuItem("E_xit");
exitMenuItem.setGraphic(new ImageView(new Image(CLOSE_ICON)));
exitMenuItem.setOnAction(new EventHandler<ActionEvent>() {
);
Menu zoomMenu = new Menu("_Zoom");
MenuItem zoomResetMenuItem = new MenuItem("Zoom _Reset");
zoomResetMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.ESCAPE));
zoomResetMenuItem.setGraphic(new ImageView(new Image(ZOOM_RESET_ICON)));
MenuItem zoomInMenuItem = new MenuItem("Zoom _In");
zoomInMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.I));
zoomInMenuItem.setGraphic(new ImageView(new Image(ZOOM_IN_ICON)));
MenuItem zoomOutMenuItem = new MenuItem("Zoom _Out");
zoomOutMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.O));
zoomOutMenuItem.setGraphic(new ImageView(new Image(ZOOM_OUT_ICON)));

代码示例来源:origin: stackoverflow.com

TextField textField = new TextField("Type Something"); // we will add a popup menu to this text field
final ContextMenu contextMenu = new ContextMenu();
MenuItem cut = new MenuItem("Cut");
MenuItem copy = new MenuItem("Copy");
MenuItem paste = new MenuItem("Paste");
contextMenu.getItems().addAll(cut, copy, paste);
cut.setOnAction(new EventHandler<ActionEvent>() {
  @Override
  public void handle(ActionEvent event) {
    System.out.println("Cut...");
  }
});
// ...
textField.setContextMenu(contextMenu);

代码示例来源:origin: stackoverflow.com

MenuItem menu1 = new MenuItem(this);
menu1.setIntent(myIntent);

代码示例来源:origin: stackoverflow.com

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;

public class ContextColor extends Application {
 public static void main(String[] args) { launch(args); }
 @Override public void start(Stage stage) {
  Label label = new Label("Right click for options");
  label.setContextMenu(new ContextMenu(new MenuItem("Help"), new MenuItem("Me")));
  Scene scene = new Scene(label);
  scene.getStylesheets().add(ContextColor.class.getResource("contextcolor.css").toExternalForm());
  stage.setScene(scene);
  stage.show();
 }
}

代码示例来源:origin: Nilhcem/FakeSMTP

/**
 * The popup menu used by the icon in the system tray.
 *
 * @param mainFrame MainFrame class.
 */
public TrayPopup(final MainFrame mainFrame) {
  // Create a popup menu components
  MenuItem aboutItem = new MenuItem(i18n.get("menubar.about"));
  aboutItem.addActionListener(new AboutActionListener(null));
  MenuItem exitItem = new MenuItem(i18n.get("menubar.exit"));
  exitItem.addActionListener(new ExitActionListener(mainFrame));
  popup.add(aboutItem);
  popup.addSeparator();
  popup.add(exitItem);
}

代码示例来源:origin: i2p/i2p.i2p

public PopupMenu getMainMenu() {
  PopupMenu popup = new PopupMenu();
  MenuItem startItem = new MenuItem(_t("Start I2P"));
  startItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent arg0) {
      new SwingWorker<Object, Object>() {
        @Override
        protected Object doInBackground() throws Exception {
          RouterManager.start();
          return null;
        }
        
        @Override
        protected void done() {
          trayIcon.displayMessage(_t("Starting"), _t("I2P is starting!"), TrayIcon.MessageType.INFO);
          //Hide the tray icon.
          //We cannot stop the desktopgui program entirely,
          //since that risks killing the I2P process as well.
          tray.remove(trayIcon);
        }
      }.execute();
    }
  });
  popup.add(startItem);
  return popup;
}

代码示例来源:origin: stackoverflow.com

MenuItem action = new MenuItem("Action");
action.addActionListener(new ActionListener() {
  @Override
MenuItem close = new MenuItem("Close");
close.addActionListener(new ActionListener() {
  @Override

代码示例来源:origin: stackoverflow.com

PopupMenu popup = new PopupMenu();
final TrayIcon trayIcon = new TrayIcon(image, "The Tip Text", popup);
MenuItem item = new MenuItem("Error");
item.addActionListener(new ShowMessageListener(trayIcon, "Error Title", "Error", TrayIcon.MessageType.ERROR));
popup.add(item);
item = new MenuItem("Warning");
item.addActionListener(new ShowMessageListener(trayIcon, "Warning Title", "Warning", TrayIcon.MessageType.WARNING));
popup.add(item);
item = new MenuItem("Info");
item.addActionListener(new ShowMessageListener(trayIcon, "Info Title", "Info", TrayIcon.MessageType.INFO));
popup.add(item);
item = new MenuItem("None");
item.addActionListener(new ShowMessageListener(trayIcon, "None Title", "None", TrayIcon.MessageType.NONE));
popup.add(item);
item = new MenuItem("Close");
item.addActionListener(new ActionListener() {

代码示例来源:origin: stackoverflow.com

public void start(Stage stage) {
  Menu fileMenu = new Menu("_File");
  MenuItem newFileMenuItem = new MenuItem("_New...");
  newFileMenuItem.setAccelerator(
    KeyCombination.keyCombination("SHORTCUT+N")

代码示例来源:origin: stackoverflow.com

MenuItem aboutItem = new MenuItem("About");
CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size");
CheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip");
Menu displayMenu = new Menu("Display");
MenuItem errorItem = new MenuItem("Error");
MenuItem warningItem = new MenuItem("Warning");
MenuItem infoItem = new MenuItem("Info");
MenuItem noneItem = new MenuItem("None");
MenuItem exitItem = new MenuItem("Exit");

代码示例来源:origin: magefree/mage

MenuItem imagesItem = new MenuItem("Download images");
MenuItem iconsItem = new MenuItem("Download icons");
MenuItem stopBlinkItem = new MenuItem("Stop blinking");
MenuItem preferencesItem = new MenuItem("Preferences...");
MenuItem aboutItem = new MenuItem("About Mage");
MenuItem exitItem = new MenuItem("Exit");

相关文章