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


Java JMenu.setHorizontalAlignment方法代码示例

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


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

示例1: getMenuPresenter

import javax.swing.JMenu; //导入方法依赖的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


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