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