java.awt.event.MouseEvent.getComponent()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(209)

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

MouseEvent.getComponent介绍

暂无

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

private void maybeShowPopup(MouseEvent e) {
 if (e.isPopupTrigger())
  treePopup.show(e.getComponent(), e.getX(), e.getY());
}

代码示例来源:origin: stackoverflow.com

//create a class which implements the MouseListener interface and
//implement the following in your overridden mouseClicked method

@Override
public void mouseClicked(MouseEvent e) {

  if (SwingUtilities.isRightMouseButton(e)) {

    int row = tree.getClosestRowForLocation(e.getX(), e.getY());
    tree.setSelectionRow(row);
    popupMenu.show(e.getComponent(), e.getX(), e.getY());
  }
}

代码示例来源:origin: magefree/mage

@Override
  public void mouseClicked(MouseEvent e) {
    visPopup.show(e.getComponent(), 0, e.getComponent().getHeight());
  }
});

代码示例来源:origin: ron190/jsql-injection

@Override
  public void mouseReleased(MouseEvent evt) {
    if (evt.isPopupTrigger()) {
      // Fix #45348: IllegalComponentStateException on show()
      try {
        menu.show(evt.getComponent(), evt.getX(), evt.getY());
      } catch (IllegalComponentStateException e) {
        LOGGER.error(e, e);
      }
      
      menu.setLocation(
        ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT
        ? evt.getXOnScreen() - menu.getWidth()
        : evt.getXOnScreen(),
        evt.getYOnScreen()
      );
    }
  }
});

代码示例来源:origin: igniterealtime/Smack

private void maybeShowPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {
      popup.show(e.getComponent(), e.getX(), e.getY());
    }
  }
}

代码示例来源:origin: wiztools/rest-client

private void showPopup(final MouseEvent e) {
    if("".equals(se_response.getText().trim())){
      // No response body
      return;
    }
    if (e.isPopupTrigger()) {
      bpm.show(e.getComponent(), e.getX(), e.getY());
    }
  }
});

代码示例来源:origin: ron190/jsql-injection

@Override
  public void mousePressed(MouseEvent e) {
    popup.applyComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()));
    if (ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT) {
      radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 6));
    } else {
      radioCustomMethod.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
    }
    
    popup.show(
      e.getComponent(),
      ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT
      ? e.getComponent().getX() - e.getComponent().getWidth() - popup.getWidth()
      : e.getComponent().getX(),
      e.getComponent().getY() + e.getComponent().getWidth()
    );
    
    popup.setLocation(
      ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT
      ? e.getComponent().getLocationOnScreen().x + e.getComponent().getWidth() - popup.getWidth()
      : e.getComponent().getLocationOnScreen().x,
      e.getComponent().getLocationOnScreen().y + e.getComponent().getWidth()
    );
  }
});

代码示例来源:origin: igniterealtime/Smack

private void maybeShowPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {
      popup.show(e.getComponent(), e.getX(), e.getY());
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void mouseMoved(MouseEvent awtEvt) {
  if (isRecentering) {
    // MHenze (cylab) Fix Issue 35:
    // As long as the MouseInput is in recentering mode, nothing is done until the mouse is entered in the component
    // by the events generated by the robot. If this happens, the last known location is resetted.
    if ((centerLocation.x == awtEvt.getX() && centerLocation.y == awtEvt.getY()) || eventsSinceRecenter++ == 5) {
      lastKnownLocation.x = awtEvt.getX();
      lastKnownLocation.y = awtEvt.getY();
      isRecentering = false;
    }
  } else {
    // MHenze (cylab) Fix Issue 35:
    // Compute the delta and absolute coordinates and recenter the mouse if necessary
    int dx = awtEvt.getX() - lastKnownLocation.x;
    int dy = awtEvt.getY() - lastKnownLocation.y;
    location.x += dx;
    location.y += dy;
    if (!visible) {
      recenterMouse(awtEvt.getComponent());
    }
    lastKnownLocation.x = awtEvt.getX();
    lastKnownLocation.y = awtEvt.getY();
    cursorMoved = true;
  }
}

代码示例来源:origin: igniterealtime/Smack

private void maybeShowPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {
      popup.show(e.getComponent(), e.getX(), e.getY());
    }
  }
}

代码示例来源:origin: deathmarine/Luyten

@Override
  public void mouseClicked(MouseEvent e) {
    if (SwingUtilities.isRightMouseButton(e)) {
      new JPopupMenu() {
        {
          JMenuItem menuitem = new JMenuItem("Select All");
          menuitem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              exception.requestFocus();
              exception.selectAll();
            }
          });
          this.add(menuitem);
          menuitem = new JMenuItem("Copy");
          menuitem.addActionListener(new DefaultEditorKit.CopyAction());
          this.add(menuitem);
        }
        private static final long serialVersionUID = 562054483562666832L;
      }.show(e.getComponent(), e.getX(), e.getY());
    }
  }
});

代码示例来源:origin: stackoverflow.com

table.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseReleased(MouseEvent e) {
    int r = table.rowAtPoint(e.getPoint());
    if (r >= 0 && r < table.getRowCount()) {
      table.setRowSelectionInterval(r, r);
    } else {
      table.clearSelection();
    }

    int rowindex = table.getSelectedRow();
    if (rowindex < 0)
      return;
    if (e.isPopupTrigger() && e.getComponent() instanceof JTable ) {
      JPopupMenu popup = createYourPopUp();
      popup.show(e.getComponent(), e.getX(), e.getY());
    }
  }
});

代码示例来源:origin: stackoverflow.com

private void maybeShowPopup(MouseEvent e) {
  if (e.isPopupTrigger()) {
   int row = table.rowAtPoint(e.getPoint());
   int[] selectedRows = table.getSelectedRows();
   if (!table.isRowSelected(row)) {
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
  }

代码示例来源:origin: wiztools/rest-client

private void showPopup(MouseEvent e) {
    if(jt.getSelectedRowCount() == 0) { // No table row selected
      jmi_rm_selected.setEnabled(false);
    }
    else {
      jmi_rm_selected.setEnabled(true);
    }
    if (e.isPopupTrigger()) {
      popupMenu.show(e.getComponent(), e.getX(), e.getY());
    }
  }
});

代码示例来源:origin: stackoverflow.com

private void maybeShowPopup(MouseEvent e) {
  if (e.isPopupTrigger()) {
   // get row that pointer is over
   int row = table.rowAtPoint(e.getPoint());
   // if pointer is over a selected row, show popup
   if (table.isRowSelected(row)) {
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
  }
}

代码示例来源:origin: wiztools/rest-client

private void showPopup(MouseEvent e) {
    if(jt_res_headers.getSelectedRowCount() == 0) {
      jmi_copy.setEnabled(false);
    }
    else {
      jmi_copy.setEnabled(true);
    }
    if (e.isPopupTrigger()) {
      popup.show(e.getComponent(), e.getX(), e.getY());
    }
  }
});

代码示例来源:origin: magefree/mage

private void checkMenu(MouseEvent Me, SimpleCardView card) {
  if (Me.isPopupTrigger()) {
    Me.consume();
    cardEventSource.fireEvent(card, Me.getComponent(), Me.getX(), Me.getY(), ClientEventType.SHOW_POP_UP_MENU);
  }
}

代码示例来源:origin: deathmarine/Luyten

public void mouseClicked(MouseEvent ev) {
    if (SwingUtilities.isRightMouseButton(ev) && isExtracting())
      menu.show(ev.getComponent(), ev.getX(), ev.getY());
  }
});

代码示例来源:origin: magefree/mage

private void checkMenu(MouseEvent Me, SimpleCardView card) {
  if (Me.isPopupTrigger()) {
    Me.consume();
    cardEventSource.fireEvent(card, Me.getComponent(), Me.getX(), Me.getY(), ClientEventType.SHOW_POP_UP_MENU);
  }
}

代码示例来源:origin: skylot/jadx

private void process(MouseEvent e) {
    textComponent.requestFocus();

    boolean enabled = textComponent.isEnabled();
    boolean editable = textComponent.isEditable();
    boolean nonempty = !(textComponent.getText() == null || textComponent.getText().equals(""));
    boolean marked = textComponent.getSelectedText() != null;
    boolean pasteAvailable = Toolkit.getDefaultToolkit().getSystemClipboard()
        .getContents(null).isDataFlavorSupported(DataFlavor.stringFlavor);

    undoAction.setEnabled(enabled && editable && undoManager.canUndo());
    redoAction.setEnabled(enabled && editable && undoManager.canRedo());
    cutAction.setEnabled(enabled && editable && marked);
    copyAction.setEnabled(enabled && marked);
    pasteAction.setEnabled(enabled && editable && pasteAvailable);
    deleteAction.setEnabled(enabled && editable && marked);
    selectAllAction.setEnabled(enabled && nonempty);

    int nx = e.getX();
    if (nx > 500) {
      nx = nx - popup.getSize().width;
    }
    popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height);
  }
}

相关文章