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


Java JMenuItem.getClientProperty方法代码示例

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


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

示例1: updateMenu

import javax.swing.JMenuItem; //导入方法依赖的package包/类
private void updateMenu (JMenu menu) {
        ActionProvider provider = getEngine().getActionProvider();
        Map context = getEngine().getContextProvider().getContext();
        String containerCtx = (String) menu.getClientProperty(KEY_CONTAINERCONTEXT);
        boolean isDynamic = getEngine().getContainerProvider().isDynamicContext(
            ContainerProvider.TYPE_MENU, containerCtx);
        
        String[] actions = provider.getActionNames(containerCtx);
//        System.err.println("Updating menu " + containerCtx + "actions: " + Arrays.asList(actions));
        
        int count = menu.getItemCount();
//        System.err.println("Item count = " + count);
        //XXX for dynamic menus, we'll need to compare the contents of the
        //menu with the list of strings, and add/prune
        
        for (int i=0; i < count; i++) {
            JMenuItem item = menu.getItem(i);
            if (item != null) {
                String action = (String) item.getClientProperty (KEY_ACTION);
                configureMenuItem (item, containerCtx, action, provider, context);
            }
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:AbstractMenuFactory.java

示例2: actionPerformed

import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
public void actionPerformed( ActionEvent e ) {
    JMenuItem source = (JMenuItem)e.getSource();

    Boolean inProject = (Boolean)source.getClientProperty( IN_PROJECT_PROPERTY );
    DataObject template = (DataObject)source.getClientProperty( TEMPLATE_PROPERTY );

    if ( inProject != null && inProject == Boolean.FALSE ) {
        doPerform( null, template, false );
    }
    else {
        doPerform( null, template, true );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:NewFile.java

示例3: getItemProject

import javax.swing.JMenuItem; //导入方法依赖的package包/类
/**
 * Get project weakly-referenced from an item.
 *
 * @param menuItem Menu item.
 *
 * @return The project, or null if it is not set or has been
 * garbage-collected.
 */
private static Project getItemProject(JMenuItem menuItem) {
    Reference<Project> p = (Reference<Project>) menuItem.getClientProperty(PROJECT_KEY);
    if (p == null) {
        return null;
    } else {
        return p.get();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SetMainProject.java

示例4: actionPerformed

import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    JMenuItem item = (JMenuItem)e.getSource();
    final BuildExecutionSupport.ActionItem ai =
            (BuildExecutionSupport.ActionItem) item.getClientProperty(DEBUG_ACTION_ITEM_PROP_NAME);
    RP.post(new Runnable() {
        @Override
        public void run() {
            ai.repeatExecution();
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:DebugMainProjectAction.java

示例5: actionPerformed

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
    JMenuItem source = (JMenuItem)(e.getSource());
    //
    // Process the event
    //
    Integer id = (Integer)source.getClientProperty(MENU_ID);
    switch (id) {
        // --------------------------------------------------------
        // OPEN SCHEMA FILE
        // --------------------------------------------------------
        case (MENU_SCHEMA_OPEN): {
            break;
        }
        // --------------------------------------------------------
        // QUIT
        // --------------------------------------------------------
        case (MENU_QUIT): {
            SchemaVisualization.this.setVisible(false);
            System.exit(0);
            break;
        }
        // --------------------------------------------------------
        // UNKNOWN
        // --------------------------------------------------------
        default:
            System.err.println("Invalid Menu Action: " + source.getName());
    } // SWITCH
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:29,代码来源:SchemaVisualization.java

示例6: actionPerformed

import javax.swing.JMenuItem; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
    JMenuItem source = (JMenuItem)(e.getSource());
    //
    // Process the event
    //
    Integer id = (Integer)source.getClientProperty(MENU_ID);
    switch (id) {
        // --------------------------------------------------------
        // OPEN SCHEMA FILE
        // --------------------------------------------------------
        case (MENU_SCHEMA_OPEN): {
            break;
        }
        // --------------------------------------------------------
        // QUIT
        // --------------------------------------------------------
        case (MENU_QUIT): {
            DesignerVisualization.this.setVisible(false);
            System.exit(0);
            break;
        }
        // --------------------------------------------------------
        // UNKNOWN
        // --------------------------------------------------------
        default:
            System.err.println("Invalid Menu Action: " + source.getName());
    } // SWITCH
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:29,代码来源:DesignerVisualization.java

示例7: actionPerformed

import javax.swing.JMenuItem; //导入方法依赖的package包/类
@Messages({
    "# {0} - URL to project directory", "STATUS_loading_recent=Loading project at {0}...",
    "ERR_InvalidProject=The project is either not valid or deleted"
})
@Override public void actionPerformed(ActionEvent e) {
    
    if ( e.getSource() instanceof JMenuItem ) {
        JMenuItem jmi = (JMenuItem)e.getSource();
        final URL url = (URL)jmi.getClientProperty( PROJECT_URL_KEY );
        StatusDisplayer.getDefault().setStatusText(STATUS_loading_recent(url));
        RP.post(new Runnable() {
            @Override public void run() {
        Project project = null;

        FileObject dir = URLMapper.findFileObject( url );
        if ( dir != null && dir.isFolder() ) {
            try {
                project = ProjectManager.getDefault().findProject( dir );
            }       
            catch ( IOException ioEx ) {
                // Ignore invalid folders
            }
        }
        
        if ( project != null ) {
            OpenProjectList.getDefault().open( new Project[] {project}, false, true );
            final String name = ProjectUtils.getInformation(project).getName();
            EventQueue.invokeLater(new Runnable() {
                @Override public void run() {
            ProjectTab ptLogical = ProjectTab.findDefault(ProjectTab.ID_LOGICAL);
            Node root = ptLogical.getExplorerManager ().getRootContext ();
            Node projNode = root.getChildren().findChild(name);
            if (projNode != null) {
                try {
                    ptLogical.getExplorerManager().setSelectedNodes(new Node[] {projNode});
                } catch (PropertyVetoException ignore) {
                    // may ignore it
                }
            } else {
                Logger.getLogger(RecentProjects.class.getName()).log(Level.WARNING, "Could not find {0} among {1}",
                        new Object[] {name, Arrays.asList(root.getChildren().getNodes())});
            }
            ProjectUtilities.makeProjectTabVisible();
                }
            });
        } else {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(ERR_InvalidProject()));
        }
            }
        });
    }
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:54,代码来源:RecentProjects.java


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