Пример #1
0
 /** Creates the alignment menu. Clients override this method to add additional menu items. */
 protected JMenu createAlignmentMenu() {
   CommandMenu menu = new CommandMenu("Align");
   menu.addCheckItem(new ToggleGridCommand("Toggle Snap to Grid", this, new Point(4, 4)));
   menu.addSeparator();
   menu.add(new UndoableCommand(new AlignCommand(AlignCommand.Alignment.LEFTS, this)));
   menu.add(new UndoableCommand(new AlignCommand(AlignCommand.Alignment.CENTERS, this)));
   menu.add(new UndoableCommand(new AlignCommand(AlignCommand.Alignment.RIGHTS, this)));
   menu.addSeparator();
   menu.add(new UndoableCommand(new AlignCommand(AlignCommand.Alignment.TOPS, this)));
   menu.add(new UndoableCommand(new AlignCommand(AlignCommand.Alignment.MIDDLES, this)));
   menu.add(new UndoableCommand(new AlignCommand(AlignCommand.Alignment.BOTTOMS, this)));
   return menu;
 }
Пример #2
0
  /** Creates the file menu. Clients override this method to add additional menu items. */
  protected JMenu createFileMenu() {
    CommandMenu menu = new CommandMenu("File");
    Command cmd =
        new AbstractCommand("New", this, false) {
          public void execute() {
            promptNew();
          }
        };
    menu.add(cmd, new MenuShortcut('n'));

    cmd =
        new AbstractCommand("Open...", this, false) {
          public void execute() {
            promptOpen();
          }
        };
    menu.add(cmd, new MenuShortcut('o'));

    cmd =
        new AbstractCommand("Save As...", this, true) {
          public void execute() {
            promptSaveAs();
          }
        };
    menu.add(cmd, new MenuShortcut('s'));
    menu.addSeparator();

    cmd =
        new AbstractCommand("Print...", this, true) {
          public void execute() {
            print();
          }
        };
    menu.add(cmd, new MenuShortcut('p'));
    menu.addSeparator();

    cmd =
        new AbstractCommand("Exit", this, true) {
          public void execute() {
            exit();
          }
        };
    menu.add(cmd);
    return menu;
  }
Пример #3
0
 /** Creates the edit menu. Clients override this method to add additional menu items. */
 protected JMenu createEditMenu() {
   CommandMenu menu = new CommandMenu("Edit");
   menu.add(new UndoableCommand(new SelectAllCommand("Select All", this)), new MenuShortcut('a'));
   menu.addSeparator();
   menu.add(new UndoableCommand(new CutCommand("Cut", this)), new MenuShortcut('x'));
   menu.add(new CopyCommand("Copy", this), new MenuShortcut('c'));
   menu.add(new UndoableCommand(new PasteCommand("Paste", this)), new MenuShortcut('v'));
   menu.addSeparator();
   menu.add(new UndoableCommand(new DuplicateCommand("Duplicate", this)), new MenuShortcut('d'));
   menu.add(new UndoableCommand(new DeleteCommand("Delete", this)));
   menu.addSeparator();
   menu.add(new UndoableCommand(new GroupCommand("Group", this)));
   menu.add(new UndoableCommand(new UngroupCommand("Ungroup", this)));
   menu.addSeparator();
   menu.add(new UndoableCommand(new SendToBackCommand("Send to Back", this)));
   menu.add(new UndoableCommand(new BringToFrontCommand("Bring to Front", this)));
   menu.addSeparator();
   menu.add(new UndoCommand("Undo Command", this));
   menu.add(new RedoCommand("Redo Command", this));
   return menu;
 }
Пример #4
0
  protected JMenu createWindowMenu() {
    CommandMenu menu = new CommandMenu("Window");
    Command cmd =
        new AbstractCommand("New View", this) {
          public void execute() {
            newView();
          }
        };
    menu.add(cmd);

    cmd =
        new AbstractCommand("New Window", this, false) {
          public void execute() {
            newWindow(createDrawing());
          }
        };
    menu.add(cmd);

    menu.addSeparator();
    menu.add(new WindowMenu("Window List", (MDIDesktopPane) getDesktop(), this));

    return menu;
  }