javax.swing.JMenuItem.putClientProperty()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中javax.swing.JMenuItem.putClientProperty()方法的一些代码示例,展示了JMenuItem.putClientProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.putClientProperty()方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:putClientProperty

JMenuItem.putClientProperty介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-awt

/** Constructor.
* @param popup pop-up menu
*/
public MenuBridge(JMenuItem item, Action action, boolean popup) {
  super(item, action);
  this.popup = popup;
  
  if (popup) {
    prepareMargins(item, action);
  } else {
    // #40824 hack
    item.putClientProperty("menubridgeresizehack", this);
    // #40824 hack end.
  }
}

代码示例来源:origin: apache/pdfbox

String name = new File(path).getName();
JMenuItem recentFileMenuItem = new JMenuItem(name);
recentFileMenuItem.putClientProperty("path", path);
recentFileMenuItem.addActionListener(recentMenuAction);
recentFilesMenu.add(recentFileMenuItem);

代码示例来源:origin: org.netbeans.api/org-openide-awt

((Actions.MenuItem)item).setBridge(b);
item.putClientProperty(DynamicMenuContent.HIDE_WHEN_DISABLED, action.getValue(DynamicMenuContent.HIDE_WHEN_DISABLED));

代码示例来源:origin: com.fifesoft.rtext/fife.common

private static JMenuItem createMenuItem(File root, String name,
    Icon icon) {
  JMenuItem item = new JMenuItem(name, icon);
  item.putClientProperty(PROPERTY_LOCATION, root);
  return item;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Constructor.
* @param popup pop-up menu
*/
public MenuBridge (JMenuItem item, Action action, boolean popup) {
  super (item, action);
  this.popup = popup;
  
  if (popup) {
    prepareMargins (item, action);
  } else {
    // #40824 hack
    item.putClientProperty("menubridgeresizehack", this);
    // #40824 hack end.
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Constructor.
* @param popup pop-up menu
*/
public MenuBridge (JMenuItem item, Action action, boolean popup) {
  super (item, action);
  this.popup = popup;
  
  if (popup) {
    prepareMargins (item, action);
  } else {
    // #40824 hack
    item.putClientProperty("menubridgeresizehack", this);
    // #40824 hack end.
  }
}

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

public void addRecentCuts(JMenu cutsMenu) {
  if (cutsMenu == null)
    return;
  cutsMenu.removeAll();
  for (int k = 0; k < recentCuts.size(); k++) {
    String str = (String) recentCuts.elementAt(k);
    JMenuItem item = new JMenuItem(maxSize(str, 60));
    item.putClientProperty("paste", str);
    cutsMenu.add(item);
    item.addActionListener(this);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-classview

private JMenuItem createItem(final CsmOffsetableDeclaration decl) {
  JMenuItem item = new JMenuItem();
  CsmFile file = decl.getContainingFile();
  item.setText(file.getName().toString());
  item.putClientProperty(PROP_DECLARATION, decl);
  item.addActionListener(this);
  return item;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-mobility-svgcore

public JMenuItem[] createMenuItems () {
    FiltersDescription filtersDesc = filters.getDescription();
    List<JMenuItem> menuItems = new ArrayList<JMenuItem>();
    for (int i = 0; i < filtersDesc.getFilterCount(); i++) {
      String filterName = filtersDesc.getName(i);
      JMenuItem menuItem = new JCheckBoxMenuItem(
          filtersDesc.getDisplayName(i), filters.isSelected(filterName)); 
      menuItem.addActionListener(this);
      menuItem.putClientProperty(PROP_FILTER_NAME, filterName);
      menuItems.add(menuItem);
    }
    return (JMenuItem[])menuItems.toArray(new JMenuItem[]{});
  }
}

代码示例来源:origin: omegat-org/omegat

protected void buildSetsMenu(JMenuBar mb) {
  m_setsMenu.removeAll();
  Mnemonics.setLocalizedText(m_setsMenu, OStrings.getString("SCW_MENU_SETS"));
  JMenuItem item = new JMenuItem();
  Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_SAVE_SET"));
  item.addActionListener(new SaveSetAction());
  m_setsMenu.add(item);
  m_setsMenu.addSeparator();
  if (m_scriptsDirectory == null) {
    return;
  }
  for (File script : m_scriptsDirectory.listFiles(script -> script.getName().endsWith(".set"))) {
    ScriptSet set = new ScriptSet(script);
    JMenuItem setMenuItem = new JMenuItem();
    setMenuItem.setText(set.getTitle());
    setMenuItem.putClientProperty("set", set);
    setMenuItem.addActionListener(new LoadSetAction());
    m_setsMenu.add(setMenuItem);
  }
  mb.add(m_setsMenu);
  //m_scriptList.setListData(items.toArray(new ScriptItem[items.size()]));
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf

item.putClientProperty("HelpID", helpID); // NOI18N

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf

private JMenuItem createSubmenu () {
  FiltersDescription filtersDesc = filters.getDescription();
  JMenuItem menu = new JMenu(NbBundle.getMessage(FilterSubmenuAction.class, "LBL_FilterSubmenu")); //NOI18N
  JMenuItem menuItem = null;
  String filterName = null;
  for (int i = 0; i < filtersDesc.getFilterCount(); i++) {
    filterName = filtersDesc.getName(i);
    menuItem = new JCheckBoxMenuItem(
        filtersDesc.getDisplayName(i), filters.isSelected(filterName)); 
    menuItem.addActionListener(this);
    menuItem.putClientProperty(PROP_FILTER_NAME, filterName);
    menu.add(menuItem);
  }
  return menu;
}

代码示例来源:origin: net.sf.squirrel-sql.plugins/graph

menuItem.putClientProperty(Sorting.CLIENT_PROP_NAME, sorting);

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

detach.putClientProperty(Content.class, content);
detach.setActionCommand("Detach");
detach.addActionListener(this);
  maximize.putClientProperty(Content.class, content);
  maximize.setActionCommand(content.isMaximized() ? "Maximize" : "Minimize");
  maximize.setText(resourceManager.getString("@@tabbed.page.restore"));
} else {
  JMenuItem maximize = new JMenuItem();
  maximize.putClientProperty(Content.class, content);
  maximize.setActionCommand("Maximize");
  maximize.setText(resourceManager.getString("@@tabbed.page.maximize"));
  minimize.putClientProperty(Content.class, content);
  minimize.setActionCommand("Minimize");
  minimize.setText(resourceManager.getString("@@tabbed.page.minimize"));

代码示例来源:origin: net.sf.ingenias/editor

/**
 * Constructor.
 *
 * @param rowCount The number of rows that will be displayed before
 *        scrolling arrows are drawn.
 */
public ScrollableJPopupMenu(int rowCount) {
  enableEvents(java.awt.AWTEvent.MOUSE_WHEEL_EVENT_MASK);
  visibleRowCount = rowCount;
  children = new ArrayList(rowCount);
  MenuMouseAdapter adapter = new MenuMouseAdapter();
  previousItem = new ArrowMenuItem(upIcon);
  previousItem.putClientProperty(PROPERTY_TIMER, previousTimer);
  previousItem.addMouseListener(adapter);
  nextItem = new ArrowMenuItem(downIcon);
  nextItem.putClientProperty(PROPERTY_TIMER, nextTimer);
  nextItem.addMouseListener(adapter);
  refresh();
}

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

/**
 * Constructor.
 *
 * @param rowCount The number of rows that will be displayed before
 * scrolling arrows are drawn.
 */
public ScrollableJPopupMenu(int rowCount) {
  enableEvents(java.awt.AWTEvent.MOUSE_WHEEL_EVENT_MASK);
  visibleRowCount = rowCount;
  children = new ArrayList(rowCount);
  MenuMouseAdapter adapter = new MenuMouseAdapter();
  previousItem = new ArrowMenuItem(upIcon);
  previousItem.putClientProperty(PROPERTY_TIMER, previousTimer);
  previousItem.addMouseListener(adapter);
  nextItem = new ArrowMenuItem(downIcon);
  nextItem.putClientProperty(PROPERTY_TIMER, nextTimer);
  nextItem.addMouseListener(adapter);
  
  refresh();
  
}

代码示例来源:origin: com.fifesoft.rtext/fife.common

/**
 * Constructor.
 *
 * @param rowCount The number of rows that will be displayed before
 *        scrolling arrows are drawn.
 */
public ScrollableJPopupMenu(int rowCount) {
  enableEvents(java.awt.AWTEvent.MOUSE_WHEEL_EVENT_MASK);
  visibleRowCount = rowCount;
  children = new ArrayList<>(rowCount);
  MenuMouseAdapter adapter = new MenuMouseAdapter();
  previousItem = new ArrowMenuItem(upIcon);
  previousItem.putClientProperty(PROPERTY_TIMER, previousTimer);
  previousItem.addMouseListener(adapter);
  nextItem = new ArrowMenuItem(downIcon);
  nextItem.putClientProperty(PROPERTY_TIMER, nextTimer);
  nextItem.addMouseListener(adapter);
  refresh();
}

代码示例来源:origin: com.fifesoft.rtext/fife.common

private void addItemsFor(File dir, ScrollableJPopupMenu popup) {
  if (dir!=null) {
    File[] children = dir.listFiles(File::isDirectory);
    // children can be null e.g. on Windows, when examining an
    // empty DVD/blu-ray drive
    int count = children!=null ? children.length : 0;
    for (int i=0; i<count; i++) {
      dir = children[i];
      Icon icon = getIcon(dir);
      JMenuItem item = new JMenuItem(dir.getName(), icon);
      if (isAncestorOfShownLocation(dir)) {
        Font font = item.getFont();
        font = font.deriveFont(Font.BOLD);
        item.setFont(font);
      }
      item.putClientProperty(PROPERTY_LOCATION, dir);
      item.addActionListener(this);
      popup.addComponent(item);
    }
  }
  else { // roots
    List<JMenuItem> roots = getRoots();
    for (JMenuItem root : roots) {
      popup.addComponent(root);
    }
  }
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
protected void installDefaults() {
  super.installDefaults();
  this.menuItem.setRolloverEnabled(true);
  // this.menuItem.setOpaque(false);
  this.arrowIcon = new MenuArrowIcon((JMenu) this.menuItem);
  this.defaultTextIconGap = SubstanceSizeUtils
      .getTextIconGap(SubstanceSizeUtils
          .getComponentFontSize(this.menuItem));
  this.menuItem.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY,
      Boolean.TRUE);
  LookAndFeel.installProperty(menuItem, "opaque", Boolean.FALSE);
}

代码示例来源:origin: org.java.net.substance/substance

@Override
protected void installDefaults() {
  super.installDefaults();
  this.menuItem.setRolloverEnabled(true);
  // this.menuItem.setOpaque(false);
  this.arrowIcon = new MenuArrowIcon((JMenu) this.menuItem);
  this.defaultTextIconGap = SubstanceSizeUtils
      .getTextIconGap(SubstanceSizeUtils
          .getComponentFontSize(this.menuItem));
  this.menuItem.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY,
      Boolean.TRUE);
  LookAndFeel.installProperty(menuItem, "opaque", Boolean.FALSE);
}

相关文章

JMenuItem类方法