List of usage examples for java.awt.event MouseEvent getComponent
public Component getComponent()
From source file:gdt.jgui.entity.webset.JWeblinkEditor.java
private void showLoginMenu(MouseEvent e) { try {/* www. java 2s .c om*/ JPopupMenu logonMenu = new JPopupMenu(); JMenuItem copyItem = new JMenuItem("Copy"); logonMenu.add(copyItem); copyItem.setHorizontalTextPosition(JMenuItem.RIGHT); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { StringSelection stringSelection = new StringSelection(loginField.getText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, JWeblinkEditor.this); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); logonMenu.show(e.getComponent(), e.getX(), e.getY()); } catch (Exception ee) { Logger.getLogger(getClass().getName()).severe(ee.toString()); } }
From source file:edu.ku.brc.specify.tasks.SystemSetupTask.java
/** * Adds the Context PopupMenu for the RecordSet. * @param roc the RolloverCommand btn to add the pop to *///from w ww . j av a 2 s .c om public void addPopMenu(final RolloverCommand roc, final PickList pickList) { if (roc.getLabelText() != null) { final JPopupMenu popupMenu = new JPopupMenu(); JMenuItem delMenuItem = new JMenuItem(getResourceString("Delete")); if (!pickList.getIsSystem()) { delMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { CommandDispatcher.dispatch(new CommandAction(SYSTEMSETUPTASK, DELETE_CMD_ACT, roc)); } }); } else { delMenuItem.setEnabled(false); } popupMenu.add(delMenuItem); JMenuItem viewMenuItem = new JMenuItem(getResourceString("EDIT")); viewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { startEditor(edu.ku.brc.specify.datamodel.PickList.class, "name", roc.getName(), roc.getName(), PICKLIST); } }); popupMenu.add(viewMenuItem); MouseListener mouseListener = new MouseAdapter() { private boolean showIfPopupTrigger(MouseEvent mouseEvent) { if (roc.isEnabled() && mouseEvent.isPopupTrigger() && popupMenu.getComponentCount() > 0) { popupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); return true; } return false; } @Override public void mousePressed(MouseEvent mouseEvent) { if (roc.isEnabled()) { showIfPopupTrigger(mouseEvent); } } @Override public void mouseReleased(MouseEvent mouseEvent) { if (roc.isEnabled()) { showIfPopupTrigger(mouseEvent); } } }; roc.addMouseListener(mouseListener); } }
From source file:org.openconcerto.erp.core.finance.accounting.element.AnalytiqueSQLElement.java
private void actionDroitOnglet(final int index, final MouseEvent e) { JPopupMenu pop = new JPopupMenu(); pop.add(new AbstractAction("Ajouter un axe") { public void actionPerformed(ActionEvent e) { if (ajoutAxeFrame == null) { ajoutAxeFrame = new AjouterAxeAnalytiqueFrame(a); }/*from w ww . ja v a 2 s. com*/ ajoutAxeFrame.pack(); ajoutAxeFrame.setVisible(true); } }); // si un onglet est selectionn if (index != -1) { pop.add(new AbstractAction("Supprimer l'axe") { public void actionPerformed(ActionEvent e) { supprimerAxe(index); } }); pop.add(new AbstractAction("Modifier le nom") { public void actionPerformed(ActionEvent aE) { actionModifierAxe(e, index); } }); } pop.show(e.getComponent(), e.getX(), e.getY()); System.out.println("Click droit onglet"); }
From source file:edu.ku.brc.specify.tasks.subpane.images.ImagesPane.java
/** * Shows the Reset menu.//w ww.ja v a2 s. c o m * @param e the mouse event */ private void showContextMenu(final MouseEvent e) { if (e.isPopupTrigger()) { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(UIRegistry.getResourceString("ES_TEXT_RESET")); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { searchText.setEnabled(true); searchText.setBackground(textBGColor); searchText.setText(""); } }); popup.add(menuItem); popup.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:org.archiviststoolkit.mydomain.DomainTableWorkSurface.java
/** * called when the mouse is pressed./* ww w . j a v a 2 s .co m*/ * * @param evt the mouse event */ public final void mousePressed(final MouseEvent evt) { if (evt.isPopupTrigger()) { pm.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:org.archiviststoolkit.mydomain.DomainTableWorkSurface.java
/** * called when the mouse is released.//from www . j a v a2 s. c o m * * @param evt the mouse event */ public final void mouseReleased(final MouseEvent evt) { if (evt.isPopupTrigger()) { pm.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param actionTree/*from w ww .j a va2 s. c om*/ */ private void registerPrintContextMenu(final JTree actionTree) { actionTree.addMouseListener(new MouseAdapter() { private void displayMenu(MouseEvent e) { if (e.isPopupTrigger()) { JPopupMenu menu = new JPopupMenu(); JMenuItem printMenu = new JMenuItem(UIRegistry.getResourceString("Print")); menu.add(printMenu); menu.show(e.getComponent(), e.getX(), e.getY()); printMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { print(actionTree); } }); } } @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); displayMenu(e); } @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); displayMenu(e); } @Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); displayMenu(e); } }); }
From source file:org.wandora.application.gui.topicpanels.ProcessingTopicPanel.java
private void showMenu(String[] struct, MouseEvent evt) { menu = UIBox.makePopupMenu(struct, this); menu.setLocation(evt.getXOnScreen() - 2, evt.getYOnScreen() - 2); menu.show(evt.getComponent(), evt.getX() - 2, evt.getY() - 2); }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java
/** * When a right button click is performed in the editor pane, a popup menu * is opened.//from w ww . ja va2 s. c o m * In case of the Scheme being internal, it won't open the Browser but * instead it will trigger the forwarded action. * * @param e The MouseEvent. */ public void mouseClicked(MouseEvent e) { Point p = e.getPoint(); SwingUtilities.convertPointToScreen(p, e.getComponent()); if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) { openContextMenu(p); } else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && currentHref != null && currentHref.length() != 0) { URI uri; try { uri = new URI(currentHref); } catch (URISyntaxException e1) { logger.error( "Failed to open hyperlink in chat window. " + "Error was: Invalid URL - " + currentHref); return; } if ("jitsi".equals(uri.getScheme())) { for (ChatLinkClickedListener l : chatLinkClickedListeners) { l.chatLinkClicked(uri); } } else GuiActivator.getBrowserLauncher().openURL(currentHref); // after opening the link remove the currentHref to avoid // clicking on the window to gain focus to open the link again this.currentHref = ""; } }
From source file:de.codesourcery.eve.skills.ui.components.impl.MarketPriceEditorComponent.java
/** * Checks whether a mouse-click event should trigger a context-sensitive * popup menu and renders the menu if so. * /*from w w w . j ava 2s.c om*/ * @param e */ private void maybeShowPopup(MouseEvent e) { if (!e.isPopupTrigger()) { return; } final int[] selectedRows = table.getSelectedRows(); if (ArrayUtils.isEmpty(selectedRows)) { final int row = table.rowAtPoint(e.getPoint()); if (row < 0) { if (log.isDebugEnabled()) { log.debug("maybeShowPopup(): Outside of table."); } return; } table.getSelectionModel().setSelectionInterval(row, row); } // translate row indices for (int i = 0; i < selectedRows.length; i++) { selectedRows[i] = table.getRowSorter().convertRowIndexToModel(selectedRows[i]); } if (populatePopupMenu(e, selectedRows)) { popupMenu.show(e.getComponent(), e.getX(), e.getY()); } }