本文整理了Java中javax.swing.JPopupMenu.getComponentCount()
方法的一些代码示例,展示了JPopupMenu.getComponentCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JPopupMenu.getComponentCount()
方法的具体详情如下:
包路径:javax.swing.JPopupMenu
类名称:JPopupMenu
方法名:getComponentCount
暂无
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* Overridden to toggle the enabled state of various
* RSyntaxTextArea-specific menu items.
*
* If you set the popup menu via {@link #setPopupMenu(JPopupMenu)}, you
* will want to override this method, especially if you removed any of the
* menu items in the default popup menu.
*
* @param popupMenu The popup menu. This will never be <code>null</code>.
* @see #createPopupMenu()
* @see #setPopupMenu(JPopupMenu)
*/
@Override
protected void configurePopupMenu(JPopupMenu popupMenu) {
super.configurePopupMenu(popupMenu);
// They may have overridden createPopupMenu()...
if (popupMenu!=null && popupMenu.getComponentCount()>0 &&
foldingMenu!=null) {
foldingMenu.setEnabled(foldManager.
isCodeFoldingSupportedAndEnabled());
}
}
代码示例来源:origin: org.netbeans.api/org-openide-awt
@Override
public void mousePressed( MouseEvent e ) {
popupMenuOperation = false;
JPopupMenu menu = getPopupMenu();
if ( menu != null && getModel() instanceof Model ) {
Model model = (Model) getModel();
if ( !model._isPressed() ) {
if( isInArrowArea( e.getPoint() ) && menu.getComponentCount() > 0 ) {
model._press();
menu.addPopupMenuListener( getMenuListener() );
menu.show( DropDownButton.this, 0, getHeight() );
popupMenuOperation = true;
}
} else {
model._release();
menu.removePopupMenuListener( getMenuListener() );
popupMenuOperation = true;
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-awt
@Override
public void mousePressed( MouseEvent e ) {
popupMenuOperation = false;
JPopupMenu menu = getPopupMenu();
if ( menu != null && getModel() instanceof Model ) {
Model model = (Model) getModel();
if ( !model._isPressed() ) {
if( isInArrowArea( e.getPoint() ) && menu.getComponentCount() > 0 ) {
model._press();
menu.addPopupMenuListener( getMenuListener() );
menu.show( DropDownToggleButton.this, 0, getHeight() );
popupMenuOperation = true;
}
} else {
model._release();
menu.removePopupMenuListener( getMenuListener() );
popupMenuOperation = true;
}
}
}
代码示例来源:origin: ron190/jsql-injection
popup.insert(panelCustomMethod, popup.getComponentCount());
代码示例来源:origin: com.fifesoft.rtext/fife.common
/**
* Returns the number of menu items and separators in the popup menu.
*
* @return The number of menu items and separators.
* @see #addMenuItem(JMenuItem)
* @see #addSeparator()
* @see #insertMenuItem(JMenuItem, int)
* @see #removeItem(int)
*/
public int getItemCount() {
return popupMenu.getComponentCount();
}
代码示例来源:origin: bcdev/beam
private static void addSeparatorIfAnyComponentsAdded(JPopupMenu popup, int componentCountBevore) {
if (popup.getComponentCount() > componentCountBevore) {
popup.addSeparator();
}
}
代码示例来源:origin: net.sf.sfac/sfac-core
public void addDefaultPopupMenuItems(JPopupMenu menu, final JTableHeader header) {
if (menu.getComponentCount() > 0) menu.addSeparator();
JMenuItem selectCols = new JMenuItem("Select Columns...");
selectCols.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showSelectionDialog(header);
}
});
menu.add(selectCols);
}
代码示例来源: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 = COUNT_JSDOC)
@Override
public int getCount() {
return super.getComponentCount();
}
代码示例来源: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: 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.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: com.jidesoft/jide-oss
/**
* Check if the popup menu should stay hidden although {@link #setPopupMenuVisible(boolean)} is invoked.
* <p/>
* The default implementation is to check if it contains any menu items. You could override this method to change the
* default behavior.
*
* @return true if the popup menu should stay invisible. Otherwise false.
*/
protected boolean shouldHidePopupMenu() {
return getPopupMenu().getComponentCount() == 0;
}
代码示例来源: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: 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: eugener/oxbow
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
if ( menu.getComponentCount() == 0 ) {
JComponent content = buildContent();
defaultSize = content.getPreferredSize();
menu.add( content );
}
beforeShow();
}
代码示例来源:origin: org.bidib.org.oxbow/swingbits
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
if ( menu.getComponentCount() == 0 ) {
JComponent content = buildContent();
defaultSize = content.getPreferredSize();
menu.add( content );
}
beforeShow();
}
代码示例来源:origin: freeplane/freeplane
private boolean fitsOnScreen(final JPopupMenu popupMenu, final Component component) {
final int itemCount = popupMenu.getComponentCount();
return itemCount < getMaxMenuItemCount() && (popupMenu.getPreferredSize().height + component.getPreferredSize().height) < MAX_HEIGHT;
}
代码示例来源: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: net.sourceforge.mydoggy/mydoggy-plaf
protected void initPopup() {
if (popupMenu == null) {
popupMenu = new JPopupMenu("TabPopup");
popupMenu.add(new SelectNextTabAction());
popupMenu.add(new SelectPreviousTabAction());
popupMenu.addSeparator();
}
for (int i = 3, size = popupMenu.getComponentCount(); i < size; i++)
popupMenu.remove(3);
for (ToolWindowTab tab : toolWindow.getToolWindowTabs())
popupMenu.add(new SelectTabAction(tab));
}
内容来源于网络,如有侵权,请联系作者删除!