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


Java JPopupMenu.setLayout方法代码示例

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


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

示例1: initializePopup

import javax.swing.JPopupMenu; //导入方法依赖的package包/类
protected void initializePopup() {
    popup = new JPopupMenu();
    popup.setLayout(new BorderLayout());
    popup.setBorder(new EmptyBorder(0, 0, 0, 0));
    popup.addPopupMenuListener(this);
    popup.add(scroller);
    popup.pack();
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:9,代码来源:JTreeComboBox.java

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