本文整理了Java中javax.swing.JPopupMenu.getComponent()
方法的一些代码示例,展示了JPopupMenu.getComponent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JPopupMenu.getComponent()
方法的具体详情如下:
包路径:javax.swing.JPopupMenu
类名称:JPopupMenu
方法名:getComponent
暂无
代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client
@Override
public Component getMenuComponent(int n) {
return (popupMenu == null) ? null : popupMenu.getComponent(n);
}
代码示例来源:origin: com.jidesoft/jide-oss
/**
* Adds a separator to the popup menu if there are menu items on it already.
*
* @param popup the popup menu.
*/
public static void addSeparatorIfNecessary(JPopupMenu popup) {
int count = popup.getComponentCount();
if (count > 0 && !(popup.getComponent(count - 1) instanceof JSeparator)) {
popup.addSeparator();
}
}
代码示例来源:origin: org.cytoscape/swing-application-impl
private int getMenuIndexByGravity(JMenuItem item) {
Double gravity = this.actionGravityMap.get(item);
Double gravityX;
for (int i=0; i < popup.getComponentCount(); i++ ){
gravityX = this.actionGravityMap.get(popup.getComponent(i));
if (gravity < gravityX){
return i;
}
}
return popup.getComponentCount();
}
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction(jsDoc = CHILD_JSDOC, params = {"index"})
@Override
public JComponent child(int aIndex) {
return (JComponent) super.getComponent(aIndex);
}
代码示例来源:origin: eugener/oxbow
@Override
public void addSeparator() {
int count = target.getComponentCount();
boolean canAddSeparator = count != 0 &&
target.getComponent(count-1).getClass() != JPopupMenu.Separator.class;
if ( canAddSeparator ) target.addSeparator();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui
public JSeparator createJSeparator() {
JMenu menu = new JMenu();
menu.addSeparator();
return (JSeparator)menu.getPopupMenu().getComponent(0);
}
代码示例来源:origin: org.bidib.org.oxbow/swingbits
@Override
public void addSeparator() {
int count = target.getComponentCount();
boolean canAddSeparator = count != 0 &&
target.getComponent(count-1).getClass() != JPopupMenu.Separator.class;
if ( canAddSeparator ) target.addSeparator();
}
代码示例来源:origin: org.cytoscape/swing-util-api
@Override
public void addMenuSeparator(final double gravity) {
final int index = getInsertLocation("-", gravity);
menu.insert(new JSeparator(), index);
final Component separator = menu.getComponent(index);
componentGravity.put(separator, gravity);
logger.info("Inserted menu separator with gravity: " + gravity);
}
代码示例来源:origin: cpesch/RouteConverter
public static Component findMenuComponent(JPopupMenu menu, String menuComponentName) {
for (int i = 0; i < menu.getComponentCount(); i++) {
Component component = menu.getComponent(i);
if (menuComponentName.equals(component.getName()))
return component;
}
return null;
}
代码示例来源:origin: de.sciss/scisslib
public void mousePressed(MouseEvent e) {
if (isEnabled() && units.size() > 1) {
requestFocus();
if (cycle) {
((UnitAction) units.get((selectedIdx + 1) % units.size())).setLabel();
((JCheckBoxMenuItem) pop.getComponent(selectedIdx)).setSelected(true);
} else {
pop.show(UnitLabel.this, 0, UnitLabel.this.getHeight());
}
}
}
});
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
/** Adds a separator to the supplied menu. The separator will only
be added, if the previous item is not a separator. */
protected void maybeAddSeparator(JMenu m) {
JPopupMenu pm = m.getPopupMenu();
if (pm.getComponentCount() > 0 //
&& !(pm.getComponent(pm.getComponentCount() - 1) instanceof JSeparator)) {
m.addSeparator();
}
}
代码示例来源:origin: freeplane/freeplane
@Override
public void acceleratorChanged(AFreeplaneAction action, KeyStroke oldStroke, KeyStroke newStroke) {
for (Entry entry : entries.entries(action)) {
Object component = new EntryAccessor().getComponent(entry);
if (component instanceof JMenu)
component = ((JMenu) component).getPopupMenu().getComponent(0);
if (component instanceof JMenuItem)
((JMenuItem) component).setAccelerator(newStroke);
}
}
}
代码示例来源:origin: uk.ac.gate.plugins/tools
/**
* Sets the action commands of all menu items to the specified command
*/
private void setMenuCommands(JPopupMenu menu, String command) {
for (int i = 0; i < menu.getComponentCount() ; i++) {
JMenuItem item = (JMenuItem) menu.getComponent(i);
item.setActionCommand(command);
}
} // setMenuCommands
代码示例来源:origin: org.orbisgis/orbisgis-view
@Override
public Component getComponent(int i) {
if(getComponentPopupMenu()==null) {
return super.getComponent(i);
} else {
return getComponentPopupMenu().getComponent(i);
}
}
代码示例来源:origin: senbox-org/snap-desktop
public static int findMenuItemPosition(JPopupMenu popupMenu, String name) {
int n = popupMenu.getComponentCount();
for (int i = 0; i < n; i++) {
Component c = popupMenu.getComponent(i);
if (c instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) c;
if (name.equals(menuItem.getName())) {
return i;
}
}
}
return -1;
}
代码示例来源:origin: orbisgis/orbisgis
@Override
public Component getComponent(int i) {
if(getComponentPopupMenu()==null) {
return super.getComponent(i);
} else {
return getComponentPopupMenu().getComponent(i);
}
}
代码示例来源:origin: bcdev/beam
public static int findMenuItemPosition(JPopupMenu popupMenu, String name) {
int n = popupMenu.getComponentCount();
for (int i = 0; i < n; i++) {
Component c = popupMenu.getComponent(i);
if (c instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) c;
if (name.equals(menuItem.getName())) {
return i;
}
}
}
return -1;
}
代码示例来源:origin: freeplane/freeplane
private JMenuItem getFirstSubMenuItem(Entry entry) {
JMenu menu = (JMenu) new EntryAccessor().getComponent(entry);
final JMenuItem menuItem = (JMenuItem) menu.getPopupMenu().getComponent(0);
return menuItem;
}
代码示例来源:origin: com.synaptix/SynaptixSwing
private int getLastMenuItemFromGroup(IViewMenu viewMenu, JMenu menu, String g) {
int i = findSeparatorIndexByName(viewMenu.getSeparators(), g);
int count = 0;
for (int n = 0; n < menu.getPopupMenu().getComponentCount(); n++) {
Component c = menu.getPopupMenu().getComponent(n);
if (c instanceof JPopupMenu.Separator) {
if (count == i) {
return n;
}
count++;
}
}
return menu.getPopupMenu().getComponentCount();
}
代码示例来源:origin: org.java.net.substance/substance
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
// go over all elements in the popup menu and mark them as
// unarmed if necessary
for (int i = 0; i < popupMenu.getComponentCount(); i++) {
Component comp = popupMenu.getComponent(i);
if (comp instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) comp;
if (menuItem.isEnabled()
&& menuItem.getModel().isArmed())
menuItem.getModel().setArmed(false);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!