当前位置: 首页>>代码示例>>Java>>正文


Java JMenuItem.setToolTipText方法代码示例

本文整理汇总了Java中javax.swing.JMenuItem.setToolTipText方法的典型用法代码示例。如果您正苦于以下问题:Java JMenuItem.setToolTipText方法的具体用法?Java JMenuItem.setToolTipText怎么用?Java JMenuItem.setToolTipText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JMenuItem的用法示例。


在下文中一共展示了JMenuItem.setToolTipText方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private void configureMenuItem (JMenuItem item, String containerCtx, String action, ActionProvider provider, Map context) {
//        System.err.println("ConfigureMenuItem: " + containerCtx + "/" + action);
        item.setName(action);
        item.putClientProperty(KEY_ACTION, action);
        item.putClientProperty(KEY_CONTAINERCONTEXT, containerCtx);
        item.putClientProperty(KEY_CREATOR, this);
        item.setText(
            provider.getDisplayName(action, containerCtx));
        item.setToolTipText(provider.getDescription(action, containerCtx));
        int state = context == null ? ActionProvider.STATE_ENABLED | ActionProvider.STATE_VISIBLE :
            provider.getState (action, containerCtx, context);
        boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0; 
        item.setEnabled(enabled);
        boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0;
        //Intentionally use enabled property
        item.setVisible(enabled);
        item.setMnemonic(provider.getMnemonic(action, containerCtx));
        item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx));
        item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16));
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AbstractContextMenuFactory.java

示例2: configureMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private void configureMenuItem (JMenuItem item, String containerCtx, String action, ActionProvider provider, Map context) {
//        System.err.println("ConfigureMenuItem: " + containerCtx + "/" + action);
        item.setName(action);
        item.putClientProperty(KEY_ACTION, action);
        item.putClientProperty(KEY_CONTAINERCONTEXT, containerCtx);
        item.putClientProperty(KEY_CREATOR, this);
        item.setText(
            provider.getDisplayName(action, containerCtx));
//        System.err.println("  item text is " + item.getText());
        item.setToolTipText(provider.getDescription(action, containerCtx));
        int state = context == null ? ActionProvider.STATE_ENABLED | ActionProvider.STATE_VISIBLE :
            provider.getState (action, containerCtx, context);
        boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0; 
//        System.err.println("action " + action + (enabled ? " enabled" : " disabled"));
        item.setEnabled(enabled);
        boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0;
//        System.err.println("action " + action + (visible ? " visible" : " invisible"));
        item.setVisible(visible);
        item.setMnemonic(provider.getMnemonic(action, containerCtx));
        item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx));
        item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16));
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:AbstractMenuFactory.java

示例3: addItemToSubMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
 * 
 * @param topLevelName
 * @param subMenuName
 * @param tooltip
 * @param enabled
 */
public void addItemToSubMenu(JMenuItem item, String topLevelName,
		String subMenuName, String tooltip, boolean enabled) {
	JMenu topLevel = (JMenu) parentMenus.get(topLevelName);
	
	if (topLevel != null) {
		Component[] components = topLevel.getMenuComponents();
		
		for (int i=0 ; i<components.length ; i++) {
			if (components[i] instanceof JMenu) {
				JMenu subMenu = (JMenu) components[i];
			
				if (subMenu.getText().equals(subMenuName)) {
					item.setToolTipText(tooltip);
					subMenu.add(item);
				}
			}
		}
	}
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:27,代码来源:Menu.java

示例4: addHelpURLItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
 * Registers a new item in the Help menu.
 *
 * @param url for the item to be opened in the browser, e.g.
 * pathToURL("docs/board.pdf"), or "http://jaerproject.net/".
 * @param title the menu item title
 * @param tooltip useful tip about help
 * @return the menu item - useful for removing the help item.
 * @see #removeHelpItem(javax.swing.JMenuItem)
 * @see #pathToURL(java.lang.String)
 */
final public JComponent addHelpURLItem(final String url, String title, String tooltip) {
    JMenuItem menuItem = new JMenuItem(title);
    menuItem.setToolTipText(tooltip);

    menuItem.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            showInBrowser(url);
            //                try {
            //                    BrowserLauncher launcher=new BrowserLauncher();
            //                    launcher.openURLinBrowser(url);
            ////                    BrowserLauncher.openURL(url);
            //                } catch (Exception e) {
            //                    log.warning(e.toString());
            //                    setStatusMessage(e.getMessage());
            //                }
        }
    });
    addHelpItem(menuItem);
    return menuItem;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:34,代码来源:AEViewer.java

示例5: updateMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
 * Add list orecentProjFile recent projects as Menu Items to the Recent
 * projects menu
 *
 *
 * @param recentProj instance orecentProjFile the menu to address
 * <code>Recent Projects</code>
 */
public void updateMenu(JMenu recentProj) {
    recentProj.removeAll();
    try {
        for (String file : recentProjects) {
            recentItemMenu = new JMenuItem();
            recentItemMenu.setFont(new java.awt.Font("sansserif", 0, 11));
            recentItemMenu.setText(toName(file));
            recentItemMenu.setToolTipText(file);
            recentProj.add(recentItemMenu);
            addlistener(recentItemMenu);
        }
    } catch (Exception ex) {
        Logger.getLogger(RecentItems.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:24,代码来源:RecentItems.java

示例6: setMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/** Sets the state of JMenuItem*/
protected @Override void setMenu(){
    
    ActionMap am = getContextActionMap();
    Action action = null;
    if (am != null) {
        action = am.get(getActionName());
    }
    
    JMenuItem presenter = getMenuPresenter();
    Action presenterAction = presenter.getAction();
    if (presenterAction == null){
        presenter.setAction(this);
        presenter.setToolTipText(null); /* bugfix #62872 */ 
        menuInitialized = false;
    } 
    else {
        if (!this.equals(presenterAction)){
            presenter.setAction(this);
            presenter.setToolTipText(null); /* bugfix #62872 */
            menuInitialized = false;
        }
    }

    if (!menuInitialized){
        Mnemonics.setLocalizedText(presenter, getMenuItemText());
        menuInitialized = true;
    }

    presenter.setEnabled(action != null);
    JTextComponent comp = Utilities.getFocusedComponent();
    if (comp != null && comp instanceof JEditorPane){
        addAccelerators(this, presenter, comp);
    } else {
        presenter.setAccelerator(getDefaultAccelerator());
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:CompletionActionsMainMenu.java

示例7: addMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
 * Adds a menu item to this menu bar, under the given parent menu. The only action
 * that will be set to this item is showing a message that the chosen functionality
 * has not been implemented; this method should be used to add to a program menu
 * items of future implementations.
 * @param name the name of the new menu item
 * @param parentName the name of the parent menu in which to add the new item
 * @param tooltip the tooltip text that will be shown when the mouse is over this item
 * @param enabled indicates whether or not the item will be enabled
 */
public void addMenuItem (String name, String parentName, String tooltip,
		boolean enabled) {
     JMenu parentMenu = (JMenu) parentMenus.get(parentName);
     
     if (parentMenu != null) {
         JMenuItem newItem = new JMenuItem(name);
		 newItem.setToolTipText(tooltip);
         EventHandler.getInstance().add(name,newItem);
         
         parentMenu.add(newItem);
     }
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:23,代码来源:Menu.java

示例8: addFunction

import javax.swing.JMenuItem; //导入方法依赖的package包/类
protected void addFunction(JMenu menu, final String op, final String desc, final String[] parms) {
  final JMenuItem item = new JMenuItem(op);
  item.setToolTipText(desc);
  item.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
      buildFunction(op, desc, parms);
    }});
  menu.add(item);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:10,代码来源:BeanShellExpressionConfigurer.java

示例9: addOperator

import javax.swing.JMenuItem; //导入方法依赖的package包/类
protected void addOperator(JMenu menu, final String op, String desc) {
  final JMenuItem item = new JMenuItem(op);
  item.setToolTipText(desc);
  item.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
      insertName(op);
    }});
  menu.add(item);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:10,代码来源:BeanShellExpressionConfigurer.java

示例10: createMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public static JMenuItem createMenuItem(String key, String text, String tooltip, Icon icon, ActionListener listener) {
	JMenuItem item = new JMenuItem(text);
	item.setToolTipText(tooltip);
	item.setActionCommand(key);
	item.setBorder(MENU_EMPTY_BORDER);
	if(icon!=null)
		item.setIcon(icon);
	item.addActionListener(listener);
	return item;
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:11,代码来源:Guitilities.java

示例11: addScenarioHandler

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
 * Adds an explication strategy action to the end of this menu.
 * @param strategyType the new exploration strategy
 */
public void addScenarioHandler(StrategyValue strategyType, String name) {
    SimulatorAction generateAction =
        this.simulator.getActions().getCheckLTLAction(strategyType, name);
    generateAction.setEnabled(false);
    this.scenarioActionMap.put(strategyType, generateAction);
    JMenuItem menuItem = add(generateAction);
    menuItem.setToolTipText(strategyType.getDescription());
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:13,代码来源:ModelCheckingMenu.java

示例12: createMenuItem

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public static JMenuItem createMenuItem(String action, String tooltip, KeyStroke keyStroke, ActionListener actionlistener) {
    JMenuItem btn = new JMenuItem();
    btn.setActionCommand(action);
    btn.setText(action);
    btn.setToolTipText("<html>" + action + (tooltip != null ? (" [" + tooltip + "]") : "") + "</html>");
    btn.setAccelerator(keyStroke);
    btn.addActionListener(actionlistener);
    return btn;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:10,代码来源:Utils.java

示例13: LineSegmentsObject

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public LineSegmentsObject( XMap map, Digitizer dig ) {
	this.map = map;
	wrap = map.getWrap();
	this.dig = dig;
	points = new Vector();
	visible = true;
	currentSeg = null;
	name = null;
	selected = false;
	lineWidth = 1f;
	color = Color.black;
	when = 0L;
	currentPoint = -1;
	editShape = null;
	active = false;
	setColor( dig.options.color );
	setFill( dig.options.fill );
	setStroke( dig.options.stroke );
	lastColor = color;
	lastFill = Color.white;
	table = 0;
	
	rightClickMenu = new JPopupMenu("Popup");
	JMenuItem deleteItem = new JMenuItem("Delete Point");
	deleteItem.setToolTipText("Click to delete");
	deleteItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          dig.deletePtsBtn.doClick();
        }
      });
	rightClickMenu.add(deleteItem);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:33,代码来源:LineSegmentsObject.java

示例14: getMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private JMenuItem getMenu(RecentItem recentItem) {
    JMenuItem menuItem = new JMenuItem(recentItem.getProjectName());
    menuItem.addActionListener(this);
    menuItem.setToolTipText(recentItem.getLocation());
    return menuItem;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:7,代码来源:RecentItems.java


注:本文中的javax.swing.JMenuItem.setToolTipText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。