當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。