本文整理匯總了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;
}