當前位置: 首頁>>代碼示例>>Java>>正文


Java WindowManager.addPropertyChangeListener方法代碼示例

本文整理匯總了Java中org.openide.windows.WindowManager.addPropertyChangeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java WindowManager.addPropertyChangeListener方法的具體用法?Java WindowManager.addPropertyChangeListener怎麽用?Java WindowManager.addPropertyChangeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.windows.WindowManager的用法示例。


在下文中一共展示了WindowManager.addPropertyChangeListener方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMenuPresenter

import org.openide.windows.WindowManager; //導入方法依賴的package包/類
public JMenuItem getMenuPresenter() {
    // beware, we shouldn't cache menu intstance, because getMenuPresenter
    // can be legally called several times and menu component cannot be
    // contained in more than one component hierarchy
    JMenu menu = new org.openide.awt.JMenuPlus();
    Mnemonics.setLocalizedText(menu, getName());
    menu.setHorizontalTextPosition(JMenu.RIGHT);
    menu.setHorizontalAlignment(JMenu.LEFT);
    menu.setIcon(getIcon());
    HelpCtx.setHelpIDString(menu, WorkspaceSwitchAction.class.getName());

    final WindowManager pool = WindowManager.getDefault();

    final Hashtable menu2Workspace = new Hashtable(10);

    // ^ maps listener on workspace
    final Hashtable workspace2Menu = new Hashtable(10);

    // ^ maps workspace to menuitem
    final Hashtable workspace2Listener = new Hashtable(10);

    // ^ maps workspace to action listener
    final Workspace[] currentDeskRef = new Workspace[1];
    currentDeskRef[0] = pool.getCurrentWorkspace();

    // attach all workspaces
    Workspace[] workspaces = pool.getWorkspaces();

    for (int i = 0; i < workspaces.length; i++) {
        attachWorkspace(workspaces[i], currentDeskRef, workspace2Menu, menu2Workspace, workspace2Listener, menu);
    }

    // check on currently active workspace
    JRadioButtonMenuItem curItem = (JRadioButtonMenuItem) workspace2Menu.get(currentDeskRef[0]);

    if (curItem != null) {
        curItem.setSelected(true);
    }

    // listen to the changes in workspaces
    pool.addPropertyChangeListener(
        getWorkspacePoolListener(workspace2Menu, menu2Workspace, workspace2Listener, currentDeskRef, menu)
    );

    return menu;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:47,代碼來源:WorkspaceSwitchAction.java


注:本文中的org.openide.windows.WindowManager.addPropertyChangeListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。