本文整理汇总了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;
}