Java Code Examples for javax.swing.JMenuItem

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project addis, under directory /application/src/main/java/org/drugis/addis/gui/.

Source file: AddisWindow.java

  18 
vote

private JMenuItem createAboutItem(){
  JMenuItem item=new JMenuItem("About");
  item.setMnemonic('a');
  item.addActionListener(new AbstractAction(){
    public void actionPerformed(    final ActionEvent arg0){
      showAboutDialog();
    }
  }
);
  return item;
}
 

Example 2

From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/desk/.

Source file: WindowMenu.java

  18 
vote

/** 
 * --------------------------------------- Public API ---------------------------------------
 * @param desktop  DOCUMENT ME!
 * @param frame    DOCUMENT ME!
 */
public void addMillFrame(final MillDesktop desktop,final MillFrame frame){
  final MaximizeFrame maximize;
  final JMenuItem menuItem;
  final FrameControlRemover remover;
  maximize=new MaximizeFrame(desktop,frame);
  menuItem=add(maximize);
  new TitleChangeListener(frame,menuItem);
  new FrameControlRemover(frame,menuItem);
}
 

Example 3

From project Clotho-Core, under directory /ClothoApps/PluginManager/src/org/clothocore/tool/pluginmanager/gui/.

Source file: RightClickPopup.java

  18 
vote

@Override public void actionPerformed(ActionEvent e){
  JMenuItem selectitem=(JMenuItem)e.getSource();
  String selected=selectitem.getText();
  if (viewerHash.containsKey(selected)) {
    ViewerWrapper vw=viewerHash.get(selected);
    Collator.putPreferredViewer(myType,vw);
    System.out.println("I set preferred " + myType + " "+ vw.getDisplayName());
  }
  popupMenu.setVisible(false);
  return;
}
 

Example 4

From project cytoscape-plugins, under directory /org.openbel.cytoscape.navigator/src/org/openbel/cytoscape/navigator/.

Source file: KamNavigatorPlugin.java

  18 
vote

private static void updateMenuState(boolean networkDestroyed){
  JMenu kiMenu=getKamPluginMenu();
  JMenuItem addNodesItem=kiMenu.getItem(0);
  JMenuItem addListItem=kiMenu.getItem(1);
  boolean hasNetworks=!Cytoscape.getNetworkSet().isEmpty();
  if (networkDestroyed && Cytoscape.getNetworkSet().size() == 1) {
    hasNetworks=false;
  }
  addNodesItem.setEnabled(hasNetworks);
  addListItem.setEnabled(hasNetworks);
}
 

Example 5

From project dawn-isencia, under directory /com.isencia.passerelle.engine/src/main/java/com/isencia/passerelle/actor/gui/graph/.

Source file: EditorGraphController.java

  18 
vote

public JMenuItem create(final JContextMenu menu,NamedObj object){
  JMenuItem retv=null;
  if (object != null && object instanceof CompositeEntity) {
    retv=menu.add(_saveInLibraryAction,"Save In Library");
  }
  return retv;
}
 

Example 6

From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/lf5/viewer/categoryexplorer/.

Source file: CategoryNodeEditor.java

  18 
vote

protected JMenuItem createPropertiesMenuItem(final CategoryNode node){
  JMenuItem result=new JMenuItem("Properties");
  result.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      showPropertiesDialog(node);
    }
  }
);
  return result;
}
 

Example 7

From project e4-rendering, under directory /com.toedter.e4.ui.workbench.renderers.swing/src/com/toedter/e4/ui/workbench/renderers/swing/.

Source file: MenuItemRenderer.java

  18 
vote

@Override public void createWidget(MUIElement element,MElementContainer<MUIElement> parent){
  if (parent != null && element instanceof MMenuItem) {
    JMenuItem menuItem=new JMenuItem();
    setItemText((MMenuItem)element,menuItem);
    element.setWidget(menuItem);
  }
}
 

Example 8

From project encog-java-workbench, under directory /src/main/java/org/encog/workbench/frames/.

Source file: EncogCommonFrame.java

  18 
vote

public JMenuItem addItem(final JMenu m,final String s,final int key){
  final JMenuItem mi=new JMenuItem(s,key);
  mi.addActionListener(this);
  m.add(mi);
  return mi;
}
 

Example 9

From project freemind, under directory /freemind/freemind/controller/.

Source file: MenuBar.java

  18 
vote

private void addAdditionalPopupActions(){
  menuHolder.addSeparator(POPUP_MENU);
  JMenuItem newPopupItem;
  if (c.getFrame().isApplet()) {
    newPopupItem=menuHolder.addAction(c.toggleMenubar,POPUP_MENU + "toggleMenubar");
    newPopupItem.setForeground(new Color(100,80,80));
  }
  newPopupItem=menuHolder.addAction(c.toggleToolbar,POPUP_MENU + "toggleToolbar");
  newPopupItem.setForeground(new Color(100,80,80));
  newPopupItem=menuHolder.addAction(c.toggleLeftToolbar,POPUP_MENU + "toggleLeftToolbar");
  newPopupItem.setForeground(new Color(100,80,80));
}
 

Example 10

From project HMS, under directory /src/main/java/com/uff/hmstpa/vision/impl/.

Source file: ScheduleSystemUI.java

  18 
vote

private void jMenu_DoctorMenuSelected(javax.swing.event.MenuEvent evt){
  jMenu_Doctor.removeAll();
  jMenu_Doctor.add(jMenuItem_Todos);
  for (  Doctor doctor : controller.retrieveDoctors()) {
    JMenuItem menuItem=new JMenuItem(doctor.getName());
    menuItem.addActionListener(this);
    jMenu_Doctor.add(menuItem);
  }
}
 

Example 11

From project imageflow, under directory /src/de/danielsenff/imageflow/gui/.

Source file: InsertUnitMenu.java

  18 
vote

/** 
 * @param name
 * @param gpanel
 * @param availableUnits
 * @param location
 */
private InsertUnitMenu(final String name,final GPanel gpanel,final Point location){
  this.setName(name);
  this.setText(name);
  this.graphPanel=gpanel;
  this.location=location;
  this.units=graphPanel.getNodeL();
  final JMenuItem mi=new JMenuItem("Comment");
  mi.setToolTipText("Insert Notes or Comments to the graph.");
  add(mi).addActionListener(this);
  final TreeModel tree=DelegatesController.getInstance().delegatesTreeModel;
  createMenu(this,(MutableTreeNode)tree.getRoot());
}
 

Example 12

From project jchempaint, under directory /src/main/org/openscience/jchempaint/.

Source file: JChemPaintPopupMenu.java

  18 
vote

/** 
 * Constructor for the JChemPaintPopupMenu object.
 * @param jcpPanel  The JChemPaintPanel this menu is used for.
 * @param type      The String used to identify the Menu
 * @param guiString The string identifying the gui to build (i. e. the properties file to use)
 * @param blacklist       A list of menuitesm/buttons which should be ignored when building gui.
 */
JChemPaintPopupMenu(JChemPaintPanel jcpPanel,String type,String guiString,List<String> blacklist){
  String menuTitle=jcpPanel.getMenuTextMaker().getText(type + "MenuTitle");
  JMenuItem titleMenuItem=new JMenuItem(menuTitle);
  titleMenuItem.setEnabled(false);
  titleMenuItem.setArmed(false);
  this.add(titleMenuItem);
  this.addSeparator();
  this.setLabel(type);
  menuHelper.createMenu(jcpPanel,type + "popup",true,guiString,this,blacklist);
}
 

Example 13

From project jMemorize, under directory /src/jmemorize/gui/swing/panels/.

Source file: CardPanel.java

  18 
vote

private JMenuItem createMenuItem(Action action,String text,String icon){
  JMenuItem item=new JMenuItem(action);
  if (action instanceof AbstractStyledTextAction)   ((AbstractStyledTextAction)action).setButton(item);
  item.setIcon(new ImageIcon(getClass().getResource("/resource/icons/" + icon)));
  item.setText(text);
  return item;
}
 

Example 14

From project jreepad, under directory /src/jreepad/editor/.

Source file: EditPopupHandler.java

  18 
vote

public void addActionItem(TextAction action,String menuLabel,String type){
  JMenuItem item=new JMenuItem(action);
  item.setText(menuLabel);
  popupMenu.add(item);
  if (itemMap.containsKey(type)) {
    itemMap.put(type,item);
  }
}
 

Example 15

From project jsmaa, under directory /main/src/main/java/fi/smaa/jsmaa/gui/.

Source file: AbstractGUIFactory.java

  18 
vote

private JMenu buildHelpMenu(){
  JMenu helpMenu=new JMenu("Help");
  helpMenu.setMnemonic('h');
  JMenuItem aboutItem=new JMenuItem("About",ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_HOME));
  aboutItem.setMnemonic('a');
  aboutItem.addActionListener(new AbstractAction(){
    public void actionPerformed(    ActionEvent arg0){
      showAboutDialog();
    }
  }
);
  helpMenu.add(aboutItem);
  return helpMenu;
}
 

Example 16

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/casemodule/.

Source file: UpdateRecentCases.java

  17 
vote

/** 
 * Creates main menu/popup menu items. Null values will be later replaced by JSeparators. This method is called for popups and for menus. It's called each time a popup menu is constructed and just once for the main menu. Main menu updates happen through the synchMenuPresenters() method.
 * @return
 */
@Override public JComponent[] getMenuPresenters(){
  String[] caseName=RecentCases.getInstance().getRecentCaseNames();
  String[] casePath=RecentCases.getInstance().getRecentCasePaths();
  JComponent[] comps=new JComponent[length + 2];
  for (int i=0; i < length; i++) {
    if ((!caseName[i].equals(""))) {
      JMenuItem menuItem=new JMenuItem(caseName[i]);
      menuItem.setActionCommand(caseName[i].toUpperCase());
      menuItem.addActionListener(new RecentItems(caseName[i],casePath[i]));
      comps[i]=menuItem;
      hasRecentCase=hasRecentCase || true;
    }
  }
  if (hasRecentCase) {
    comps[length]=new JSeparator();
    JMenuItem clearMenu=new JMenuItem("Clear Recent Cases");
    clearMenu.addActionListener(SystemAction.get(RecentCases.class));
    comps[length + 1]=clearMenu;
  }
 else {
    comps=new JComponent[1];
    JMenuItem emptyMenu=new JMenuItem("-Empty-");
    emptyMenu.addActionListener(new RecentItems("",""));
    comps[0]=emptyMenu;
    comps[0].setEnabled(false);
  }
  return comps;
}
 

Example 17

From project Briss, under directory /src/main/java/at/laborg/briss/gui/.

Source file: MergedPanel.java

  17 
vote

public PopUpMenuForCropRectangles(){
  boolean isContainedInRectangle=false;
  for (  DrawableCropRect crop : crops) {
    if (crop.contains(popUpMenuPoint)) {
      isContainedInRectangle=true;
    }
  }
  if (isContainedInRectangle) {
    JMenuItem deleteItem=new JMenuItem(DELETE);
    deleteItem.addActionListener(MergedPanelMouseAdapter.this);
    add(deleteItem);
    JMenuItem selectDeselectItem=new JMenuItem(SELECT_DESELECT);
    selectDeselectItem.addActionListener(MergedPanelMouseAdapter.this);
    add(selectDeselectItem);
  }
  boolean copyPossible=false;
  for (  DrawableCropRect crop : crops) {
    if (crop.isSelected()) {
      copyPossible=true;
    }
  }
  JMenuItem copyItem=new JMenuItem(COPY);
  copyItem.addActionListener(MergedPanelMouseAdapter.this);
  copyItem.setEnabled(copyPossible);
  add(copyItem);
  JMenuItem pasteItem=new JMenuItem(PASTE);
  pasteItem.addActionListener(MergedPanelMouseAdapter.this);
  pasteItem.setEnabled(ClipBoard.getInstance().getAmountOfCropsInClipBoard() > 0);
  add(pasteItem);
  JMenuItem alignItem=new JMenuItem(ALIGN_SELECTED);
  alignItem.addActionListener(MergedPanelMouseAdapter.this);
  alignItem.setEnabled(true);
  add(alignItem);
}
 

Example 18

From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/activation/impl/.

Source file: JMenuIterator.java

  17 
vote

private void computePopupMenu(MenuElement menuElement,String parentPath){
  MenuElement[] subElements=menuElement.getSubElements();
  for (  MenuElement subElement : subElements) {
    if (subElement instanceof JPopupMenu) {
      JPopupMenu popupMenu=(JPopupMenu)subElement;
      computePopupMenu(popupMenu,parentPath);
    }
 else     if (subElement instanceof JMenu) {
      JMenu subMenu=(JMenu)subElement;
      menuList.add(new JComponentPod(subMenu,parentPath + ":" + subMenu.getText()));
      if (subMenu.getSubElements().length > 0) {
        computePopupMenu(subMenu.getSubElements()[0],parentPath + ":" + subMenu.getText());
      }
    }
 else     if (subElement instanceof JMenuItem) {
      JMenuItem menuItem=(JMenuItem)subElement;
      menuList.add(new JComponentPod(menuItem,parentPath + ":" + menuItem.getText()));
    }
  }
}
 

Example 19

From project dawn-common, under directory /org.dawb.hdf5/src/ncsa/hdf/view/.

Source file: DefaultTableView.java

  17 
vote

/** 
 * creates a popup menu for a right mouse click on a data object 
 */
private JPopupMenu createPopupMenu(){
  JPopupMenu menu=new JPopupMenu();
  JMenuItem item;
  item=new JMenuItem("Show As Table");
  item.setMnemonic(KeyEvent.VK_T);
  item.addActionListener(this);
  item.setActionCommand("Show data as table");
  menu.add(item);
  item=new JMenuItem("Show As Image");
  item.setMnemonic(KeyEvent.VK_I);
  item.addActionListener(this);
  item.setActionCommand("Show data as image");
  menu.add(item);
  return menu;
}
 

Example 20

From project enclojure, under directory /netbeans/plugins/org-enclojure-plugin/src/main/java/org/enclojure/ide/nb/actions/.

Source file: DebugProjectWithReplContextMenuAction.java

  17 
vote

public JMenuItem getPopupPresenter(){
class Presenter extends JMenuItem implements DynamicMenuContent {
    public Presenter(){
      super(ContextAction.this);
    }
    public JComponent[] getMenuPresenters(){
      if (p != null) {
        Mnemonics.setLocalizedText(this,labelFor(p));
        return new JComponent[]{this};
      }
 else {
        return new JComponent[0];
      }
    }
    public JComponent[] synchMenuPresenters(    JComponent[] items){
      return getMenuPresenters();
    }
  }
  JMenuItem menuItem=new Presenter();
  return menuItem;
}
 

Example 21

From project Euclidean-Pattern-Generator, under directory /src/com/hisschemoller/sequencer/view/components/.

Source file: MenuBar.java

  17 
vote

public MenuBar(ActionListener actionListener){
  int shortcut=Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
  _fileMenu=new JMenu("File");
  add(_fileMenu);
  JMenuItem menuItem=new JMenuItem("New Project");
  menuItem.addActionListener(actionListener);
  menuItem.setActionCommand(NEW);
  menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,shortcut));
  _fileMenu.add(menuItem);
  menuItem=new JMenuItem("Open Project...");
  menuItem.addActionListener(actionListener);
  menuItem.setActionCommand(OPEN);
  menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,shortcut));
  _fileMenu.add(menuItem);
  menuItem=new JMenuItem("Save Project");
  menuItem.addActionListener(actionListener);
  menuItem.setActionCommand(SAVE);
  menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,shortcut));
  _fileMenu.add(menuItem);
  menuItem=new JMenuItem("Save Project As...");
  menuItem.addActionListener(actionListener);
  menuItem.setActionCommand(SAVE_AS);
  menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,shortcut | InputEvent.SHIFT_DOWN_MASK));
  _fileMenu.add(menuItem);
  _helpMenu=new JMenu("Help");
  add(_helpMenu);
  menuItem=new JMenuItem("Help Contents");
  menuItem.addActionListener(actionListener);
  menuItem.setActionCommand(HELP);
  _helpMenu.add(menuItem);
}
 

Example 22

From project gitblit, under directory /src/com/gitblit/client/.

Source file: GitblitManager.java

  17 
vote

private JMenuBar setupMenu(){
  JMenuBar menuBar=new JMenuBar();
  JMenu serversMenu=new JMenu(Translation.get("gb.servers"));
  menuBar.add(serversMenu);
  recentMenu=new JMenu(Translation.get("gb.recent"));
  serversMenu.add(recentMenu);
  JMenuItem manage=new JMenuItem(Translation.get("gb.manage") + "...");
  manage.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M,KeyEvent.CTRL_DOWN_MASK,false));
  manage.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent event){
      manageRegistrations();
    }
  }
);
  serversMenu.add(manage);
  return menuBar;
}
 

Example 23

From project Gmote, under directory /gmoteserver/src/org/gmote/server/.

Source file: GmoteServerUiMac.java

  17 
vote

void initializeUi(){
  JMenuItem item;
  try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (Integer.parseInt(System.getProperty("java.version").substring(2,3)) >= 5)   System.setProperty("javax.swing.adjustPopupLocationToFit","false");
  popupMenu=new JPopupMenu("Gmote Menu");
  addMediaPlayerControls();
  JMenu settingsMenu=new JMenu("Settings");
  popupMenu.add(settingsMenu);
  item=new JMenuItem("Change password");
  item.addActionListener(settingsListener);
  settingsMenu.add(item);
  item=new JMenuItem("Change media paths");
  item.addActionListener(mediaPathListener);
  settingsMenu.add(item);
  JMenu helpMenu=new JMenu("Help");
  popupMenu.add(helpMenu);
  item=new JMenuItem("Show local ip address");
  item.addActionListener(ipAddressListener);
  helpMenu.add(item);
  item=new JMenuItem("Show settings and logs folder");
  item.addActionListener(logFolderListener);
  helpMenu.add(item);
  item=new JMenuItem("Connection Help");
  item.addActionListener(helpListener);
  helpMenu.add(item);
  popupMenu.addSeparator();
  item=new JMenuItem("Quit");
  item.addActionListener(exitListener);
  popupMenu.add(item);
  ImageIcon i=new ImageIcon(GmoteServerUiMac.class.getResource("/res/gmote_icon_s.png"));
  trayIcon=new TrayIcon(i,"Gmote",popupMenu);
  trayIcon.setIconAutoSize(true);
  tray.addTrayIcon(trayIcon);
}
 

Example 24

From project groovejaar, under directory /src/groovejaar/.

Source file: GrooveJaar.java

  17 
vote

private void makeLoginMenu(){
  mnLogged.setText("Logged in as: " + user.result.username);
  mnGroove.remove(mntmLogin);
  try {
    playlists=JGroovex.userGetPlaylists(user.result.userID).result.Playlists;
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  if (playlists.length == 0)   mnPlaylist.add(new JMenuItem("No playlist"));
 else   for (int i=0; i < playlists.length; i++) {
    final String id=playlists[i].get("PlaylistID");
    final String name=playlists[i].get("Name");
    JMenuItem item=new JMenuItem(playlists[i].get("Name"));
    item.addActionListener(new ActionListener(){
      public void actionPerformed(      ActionEvent arg0){
        search(name + ":" + id,"playlist");
      }
    }
);
    mnPlaylist.add(item);
  }
  mnLogged.add(mnPlaylist);
  mnLogged.add(mnUserLib);
  mnLogged.add(mnFav);
  mnGroove.add(mnLogged);
}
 

Example 25

From project harmony, under directory /harmony.ui.topologygui/src/main/java/org/opennaas/ui/topology/.

Source file: TopologyClient.java

  17 
vote

/** 
 * This method initializes jMenuItem
 * @return javax.swing.JMenuItem
 */
private JMenuItem getExitMenuItem(){
  if (this.exitMenuItem == null) {
    this.exitMenuItem=new JMenuItem();
    this.exitMenuItem.setText("Exit");
    this.exitMenuItem.addActionListener(new ActionListener(){
      public void actionPerformed(      final ActionEvent e){
        System.exit(0);
      }
    }
);
  }
  return this.exitMenuItem;
}
 

Example 26

From project ib-ruby, under directory /misc/IBController 2-9-0/src/ibcontroller/.

Source file: ConfigureApiTask.java

  17 
vote

private void configureIt(){
  JFrame jf=TwsListener.getMainWindow();
  if (jf == null) {
    System.err.println("IBControllerServer: could not find main window to configure API");
    mChannel.writeNack("main window not found");
    return;
  }
  Utils.logToConsole("Attempting to configure API");
  JMenuItem jmi=Utils.findMenuItem(jf,new String[]{"Configure","API","Enable ActiveX and Socket Clients"});
  if (jmi != null) {
    configureItViaConfigureMenu((JCheckBoxMenuItem)jmi);
  }
 else {
    jmi=Utils.findMenuItem(jf,new String[]{"Edit","Global Configuration..."});
    if (jmi != null) {
      configureItViaEditMenu(jmi);
    }
 else {
      System.err.println("IBControllerServer: could not find Configure > API > Enable ActiveX or Edit > Global Configuration menus");
      mChannel.writeNack("Configure > API > Enable ActiveX or Edit > Global Configuration menus not found");
    }
  }
}
 

Example 27

From project JaamSim, under directory /com/sandwell/JavaSimulation3D/.

Source file: PickingListener.java

  17 
vote

private void processMenuClick(MouseEvent e){
  ArrayList<DisplayEntity> entList=getEntityList(e);
  menu.removeAll();
  if (entList.size() == 1) {
    entList.get(0).addMenuItems(menu,e.getX(),e.getY());
  }
 else {
    for (int i=0; i < entList.size(); i++) {
      final DisplayEntity thisEnt=entList.get(i);
      final Point pt=new Point(e.getX(),e.getY());
      final Component canvas=e.getComponent();
      JMenuItem thisItem=new JMenuItem(thisEnt.getName());
      thisItem.addActionListener(new ActionListener(){
        public void actionPerformed(        ActionEvent event){
          menu.removeAll();
          thisEnt.addMenuItems(menu,pt.x,pt.y);
          menu.show(canvas,pt.x,pt.y);
        }
      }
);
      menu.add(thisItem);
    }
  }
  menu.show(e.getComponent(),e.getX(),e.getY());
}
 

Example 28

From project jCAE, under directory /jcae/core/src/org/jcae/netbeans/cad/.

Source file: BooleanAction.java

  17 
vote

public javax.swing.JMenuItem getMenuPresenter(){
  JMenu menu=new JMenu();
  Mnemonics.setLocalizedText(menu,getName());
  JMenuItem item=new JMenuItem();
  Mnemonics.setLocalizedText(item,item.getText());
  Actions.connect(item,(Action)SystemAction.get(Common.class),true);
  menu.add(item);
  item=new JMenuItem();
  Mnemonics.setLocalizedText(item,item.getText());
  Actions.connect(item,(Action)SystemAction.get(Fuse.class),true);
  menu.add(item);
  item=new JMenuItem();
  Mnemonics.setLocalizedText(item,item.getText());
  Actions.connect(item,(Action)SystemAction.get(Cut.class),true);
  menu.add(item);
  item=new JMenuItem();
  Mnemonics.setLocalizedText(item,item.getText());
  Actions.connect(item,(Action)SystemAction.get(Section.class),true);
  menu.add(item);
  return menu;
}
 

Example 29

From project jlac, under directory /src/org/sump/analyzer/.

Source file: Diagram.java

  17 
vote

/** 
 * Create a new empty diagram to be placed in a container.
 */
public Diagram(){
  super();
  this.size=new Dimension(25,1);
  this.signal=new Color(0,0,196);
  this.trigger=new Color(196,255,196);
  this.grid=new Color(196,196,196);
  this.text=new Color(0,0,0);
  this.time=new Color(0,0,0);
  this.groupBackground=new Color(242,242,242);
  this.background=new Color(255,255,255);
  this.label=new Color(255,196,196);
  this.cursorA=new Color(190,120,0);
  this.cursorB=new Color(190,120,0);
  this.offsetX=25;
  this.offsetY=18;
  zoomDefault();
  setBackground(background);
  this.addMouseListener(this);
  this.addMouseMotionListener(this);
  this.contextMenuPosition=new Point();
  this.contextMenu=new JPopupMenu();
  JMenuItem gotoA=new JMenuItem("Set Cursor A");
  gotoA.addActionListener(this);
  this.contextMenu.add(gotoA);
  JMenuItem gotoB=new JMenuItem("Set Cursor B");
  gotoB.addActionListener(this);
  this.contextMenu.add(gotoB);
  this.settings=new DiagramSettings();
  this.capturedData=null;
  this.labels=new DiagramLabels();
  this.cursorDefault=this.getCursor();
  this.cursorDrag=new Cursor(Cursor.MOVE_CURSOR);
  this.draggedCursor=0;
  this.curListners=new Vector<DiagramCursorChangeListener>();
  this.maxScale=10.0;
  this.timeDivider=1;
  this.maxPages=1;
  this.currentPage=0;
  this.pageLen=0;
}
 

Example 30

From project joshua, under directory /src/joshua/ui/tree_visualizer/browser/.

Source file: FileChoiceListener.java

  17 
vote

public void actionPerformed(ActionEvent e){
  if (fileChooser.showOpenDialog(enclosingFrame) == JFileChooser.APPROVE_OPTION) {
    JMenuItem eventSource=(JMenuItem)e.getSource();
    File chosenFile=fileChooser.getSelectedFile();
    try {
      if (eventSource.equals(src)) {
        Browser.getTranslationInfo().setSourceFile(chosenFile);
      }
      if (eventSource.equals(ref)) {
        Browser.getTranslationInfo().setReferenceFile(chosenFile);
      }
      if (eventSource.equals(nBest)) {
        Browser.getTranslationInfo().addNBestFile(chosenFile);
        Browser.activeFrame.add(new DerivationTreeFrame(Browser.activeFrame.size()));
      }
    }
 catch (    IOException ioe) {
      JOptionPane.showMessageDialog(enclosingFrame,"An I/O exception occurred: " + ioe.getMessage(),"IOException",JOptionPane.WARNING_MESSAGE);
    }
  }
  return;
}
 

Example 31

From project collaborative-editor, under directory /mpedit/gui/.

Source file: CMenu.java

  16 
vote

/** 
 * Creates menus out of given arguments
 * @param title The menutitle
 * @param menuItems The items of the menu
 * @param menuShortcuts The keyboard shortcuts for the respective items
 * @param listener The ActionListener which belongs to this menu
 * @param seperators Positions where we should insert Seperators
 * @return tmpMenu The created menu
 */
private JMenu createMenu(String title,String[] menuItems,char[] menuShortcuts,ActionListener listener,int[] seperators,char menuname){
  JMenu tmpMenu=new JMenu(title);
  JMenuItem[] items=new JMenuItem[menuItems.length];
  for (int i=0; i < menuItems.length; i++) {
    if (menuShortcuts[i] == ' ')     items[i]=new JMenuItem(menuItems[i]);
 else     items[i]=new JMenuItem(menuItems[i],menuShortcuts[i]);
    if (!(menuShortcuts[i] == ' ')) {
      items[i].setAccelerator(KeyStroke.getKeyStroke(menuShortcuts[i],Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(),false));
    }
    items[i].addActionListener(listener);
    tmpMenu.add(items[i]);
  }
  for (int i=0; i < seperators.length; i++)   tmpMenu.insertSeparator(seperators[i]);
  if (menuname == 'f')   m_fileItems=items;
 else   if (menuname == 'e')   m_editItems=items;
 else   if (menuname == 'c')   m_connItems=items;
  return tmpMenu;
}
 

Example 32

From project glg2d, under directory /src/test/java/glg2d/.

Source file: UIDemo.java

  16 
vote

JComponent createMDIComponent(){
  JDesktopPane pane=new JDesktopPane();
  pane.setDragMode(JDesktopPane.LIVE_DRAG_MODE);
  pane.setBackground(new JPanel().getBackground());
  pane.setOpaque(true);
  pane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  for (int i=0; i < 3; i++) {
    JInternalFrame frame1=new JInternalFrame("Foo" + i,true);
    frame1.setClosable(true);
    frame1.setMaximizable(true);
    pane.add(frame1);
    JMenuBar bar=new JMenuBar();
    JMenu menu=new JMenu("File");
    menu.add(new JMenuItem("Open"));
    menu.add(new JMenuItem("Close"));
    bar.add(menu);
    frame1.setJMenuBar(bar);
    frame1.setSize(200,200);
    frame1.setLocation(100 * i,5 * i);
    frame1.setVisible(true);
  }
  return pane;
}
 

Example 33

From project jreversepro, under directory /src/main/java/org/jreversepro/gui/.

Source file: MainMenu.java

  16 
vote

private void initMenuItems(){
  onFileOpen=new JMenuItem("Open");
  onFileSave=new JMenuItem("Save");
  onFileExit=new JMenuItem("Exit");
  onEditCut=new JMenuItem("Cut");
  onEditCopy=new JMenuItem("Copy");
  onViewCPool=new JMenuItem("ConstantPool");
  onOptFont=new JMenuItem("Set Font ");
  onDisAssembler=new JRadioButtonMenuItem("DisAssemble",true);
  onDecompiler=new JRadioButtonMenuItem("Decompile");
  group=new ButtonGroup();
  group.add(onDisAssembler);
  group.add(onDecompiler);
  onHelpAbout=new JMenuItem("About");
}
 

Example 34

From project Chess_1, under directory /src/chess/gui/.

Source file: WorldFrame.java

  15 
vote

private void configureMenuItem(JMenuItem item,String resource,ActionListener listener){
  configureAbstractButton(item,resource);
  item.addActionListener(listener);
  try {
    String accel=resources.getString(resource + ".accel");
    String metaPrefix="@";
    if (accel.startsWith(metaPrefix)) {
      int menuMask=getToolkit().getMenuShortcutKeyMask();
      KeyStroke key=KeyStroke.getKeyStroke(KeyStroke.getKeyStroke(accel.substring(metaPrefix.length())).getKeyCode(),menuMask);
      item.setAccelerator(key);
    }
 else {
      item.setAccelerator(KeyStroke.getKeyStroke(accel));
    }
  }
 catch (  MissingResourceException ex) {
  }
}
 

Example 35

From project codjo-standalone-common, under directory /src/main/java/net/codjo/utils/sql/.

Source file: DbToolBar.java

  15 
vote

private void setNameForPopUpMenuForTest(){
  try {
    Component[] component=popupMenu.getComponents();
    for (    Component aComponent : component) {
      if (aComponent instanceof JMenuItem) {
        aComponent.setName("popUpMenu." + ((JMenuItem)aComponent).getAction().getValue(AbstractAction.NAME));
      }
    }
  }
 catch (  Exception ex) {
  }
}
 

Example 36

From project jASM_16, under directory /src/main/java/de/codesourcery/jasm16/ide/ui/.

Source file: MenuManager.java

  15 
vote

public void setMenuItem(JMenuItem menuItem){
  if (menuItem == null) {
    throw new IllegalArgumentException("menuItem must not be null");
  }
  this.menuItem=menuItem;
}
 

Example 37

From project jftp, under directory /src/main/java/com/myjavaworld/gui/.

Source file: MMenu.java

  15 
vote

@Override public JMenuItem add(Action action){
  MMenuItem mi=new MMenuItem(action);
  mi.setIcon(null);
  add(mi);
  return mi;
}
 

Example 38

From project jSite, under directory /src/main/java/de/todesbaum/jsite/main/.

Source file: Main.java

  15 
vote

/** 
 * {@inheritDoc}
 */
@Override public void nodeSelected(Node node){
  for (  Component menuItem : nodeMenu.getMenuComponents()) {
    if (menuItem instanceof JMenuItem) {
      if (node.equals(((JMenuItem)menuItem).getClientProperty("Node"))) {
        ((JMenuItem)menuItem).setSelected(true);
      }
    }
  }
  freenetInterface.setNode(node);
  selectedNode=node;
}