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


Java JPopupMenu.setVisible方法代码示例

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


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

示例1: doSelect

import javax.swing.JPopupMenu; //导入方法依赖的package包/类
private void doSelect(JComponent owner) {
    invokingComponent = owner;
    invokingComponent.addMouseListener(this);
    invokingComponent.addMouseMotionListener(this);
    pTable.addMouseListener(this);
    pTable.addMouseMotionListener(this);
    pTable.getSelectionModel().addListSelectionListener( this );

    displayer.getModel().addComplexListDataListener( this );

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);

    popup = new JPopupMenu();
    popup.setBorderPainted( false );
    popup.setBorder( BorderFactory.createEmptyBorder() );
    popup.add( pTable );
    popup.pack();
    int locationX = x - (int) pTable.getPreferredSize().getWidth();
    int locationY = y + 1;
    popup.setLocation( locationX, locationY );
    popup.setInvoker( invokingComponent );
    popup.addPopupMenuListener( this );
    popup.setVisible( true );
    shown = true;
    invocationTime = System.currentTimeMillis();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ButtonPopupSwitcher.java

示例2: doSelect

import javax.swing.JPopupMenu; //导入方法依赖的package包/类
private void doSelect(JComponent owner) {
    invokingComponent = owner;
    invokingComponent.addMouseListener(this);
    invokingComponent.addMouseMotionListener(this);
    pTable.addMouseListener(this);
    pTable.addMouseMotionListener(this);
    pTable.getSelectionModel().addListSelectionListener( this );

    controller.getTabModel().addComplexListDataListener( this );

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);

    popup = new JPopupMenu();
    popup.setBorderPainted( false );
    popup.setBorder( BorderFactory.createEmptyBorder() );
    popup.add( pTable );
    popup.pack();
    int locationX = x - (int) pTable.getPreferredSize().getWidth();
    int locationY = y + 1;
    popup.setLocation( locationX, locationY );
    popup.setInvoker( invokingComponent );
    popup.addPopupMenuListener( this );
    popup.setVisible( true );
    shown = true;
    invocationTime = System.currentTimeMillis();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ButtonPopupSwitcher.java

示例3: dynamicChange

import javax.swing.JPopupMenu; //导入方法依赖的package包/类
public static void dynamicChange(final JPopupMenu popup, boolean usedToBeContained) {
        if (!popup.isShowing()) {
            return;
        }

        if (isProblemConfig()) {
            callRefreshLater(popup);

            return;
        }

        refreshPopup(popup);

        Point p = popup.getLocationOnScreen();
        Point newPt = getPopupMenuOrigin(popup, p);

        boolean willBeContained = willPopupBeContained(popup, newPt);

        if (usedToBeContained != willBeContained) {
            popup.setVisible(false);
        }

        if (!newPt.equals(p)) {
//            if (!NO_POPUP_PLACEMENT_HACK) {
//                popup.setLocation(newPt.x, newPt.y);
//            }
        }

        if (usedToBeContained != willBeContained) {
            popup.setVisible(true);
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:JPopupMenuUtils.java

示例4: hidePopupMenu

import javax.swing.JPopupMenu; //导入方法依赖的package包/类
public void hidePopupMenu() {
    JPopupMenu pm = getPopupMenu();
    if (pm != null) {
        pm.setVisible(false);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:EditorUI.java

示例5: dynamicChangeToSubmenu

import javax.swing.JPopupMenu; //导入方法依赖的package包/类
public static void dynamicChangeToSubmenu(JPopupMenu popup, boolean usedToBeContained) {
    Object invoker = popup.getInvoker();

    if (!(invoker instanceof JMenu)) {
        return;
    }

    JMenu menu = (JMenu) invoker;

    if (!popup.isShowing()) {
        return;
    }

    if (isProblemConfig()) {
        callRefreshLater2(popup, menu);

        return;
    }

    refreshPopup(popup);

    Point p = popup.getLocationOnScreen();
    Dimension popupSize = popup.getPreferredSize();
    Rectangle popupRect = new Rectangle(p, popupSize);
    Rectangle screenRect = getScreenRect();
    boolean willBeContained = isPopupContained(popup);

    if (!screenRect.contains(popupRect)) {
        /*
         * The menu grew off the edge of the screen.
         */
        menu.setPopupMenuVisible(false);
        menu.setPopupMenuVisible(true);
    } else if (usedToBeContained != willBeContained) {
        /*
         * The menu grew off the edge of the containing window.
         * Use the setVisible() hack to change the menu from
         * lightweight to heavyweight.
         */
        popup.setVisible(false);
        popup.setVisible(true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:JPopupMenuUtils.java

示例6: actionPerformed

import javax.swing.JPopupMenu; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
  int index = -1;
  if (highlightedChainAnnotsOffsets != null) {
    for (int i = 0; i < highlightedChainAnnotsOffsets.length; i += 2) {
      if (textLocation >= highlightedChainAnnotsOffsets[i] &&
          textLocation <= highlightedChainAnnotsOffsets[i + 1]) {
        index = (i == 0) ? i : i / 2;
        break;
      }
    }
  }

  // yes it is put on highlighted so show the annotationType
  if (highlightedChainAnnotsOffsets != null &&
      index < highlightedChainAnnotsOffsets.length && index >= 0) {
    return;
  }

  if (highlightedTypeAnnotsOffsets != null) {
    for (int i = 0; i < highlightedTypeAnnotsOffsets.length; i += 2) {
      if (textLocation >= highlightedTypeAnnotsOffsets[i] &&
          textLocation <= highlightedTypeAnnotsOffsets[i + 1]) {
        index = (i == 0) ? i : i / 2;
        break;
      }
    }
  }

  // yes it is put on highlighted so show the annotationType
  if (highlightedTypeAnnotsOffsets != null &&
      index < highlightedTypeAnnotsOffsets.length && index >= 0) {
    textPane.removeAll();
    annotToConsiderForChain = highlightedTypeAnnots.get(index);
    // now check if this annotation is already linked with something
    CorefTreeNode headNode = findOutTheChainHead(annotToConsiderForChain, (String) annotSets.getSelectedItem());
    if (headNode != null) {
      popup1 = new JPopupMenu();
      popup1.setBackground(UIManager.getLookAndFeelDefaults().
                           getColor("ToolTip.background"));
      JLabel label1 = new JLabel("Annotation co-referenced to : \"" +
                                 headNode.toString() + "\"");
      popup1.setLayout(new FlowLayout());
      popup1.add(label1);
      if (popupWindow != null && popupWindow.isVisible()) {
        popupWindow.setVisible(false);
      }
      popup1.setVisible(true);
      popup1.show(textPane, (int) mousePoint.getX(), (int) mousePoint.getY());
    }
    else {
      popupWindow.setVisible(false);
      List<String> set = new ArrayList<String>(currentSelections.keySet());
      Collections.sort(set);
      set.add(0, "[New Chain]");
      model = new DefaultComboBoxModel<String>(set.toArray(new String[set.size()]));
      list.setModel(model);
      listEditor.setItem("");
      label.setText("Add \"" + getString(annotToConsiderForChain) +
                    "\" to ");
      Point topLeft = textPane.getLocationOnScreen();
      int x = topLeft.x + (int) mousePoint.getX();
      int y = topLeft.y + (int) mousePoint.getY();
      popupWindow.setLocation(x, y);
      if (popup1.isVisible()) {
        popup1.setVisible(false);
      }
      popupWindow.pack();
      popupWindow.setVisible(true);
      listEditor.requestFocus();

      if (firstTime) {
        firstTime = false;
        popupWindow.pack();
        popupWindow.repaint();
        listEditor.requestFocus();
      }
    }
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:81,代码来源:CorefEditor.java


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