Refine search
String[] items = {"A", "B", "C", "D"}; JList list = new JList(items); list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JList list = (JList)evt.getSource(); if (evt.getClickCount() == 2) { // Double-click detected int index = list.locationToIndex(evt.getPoint()); } else if (evt.getClickCount() == 3) { // Triple-click detected int index = list.locationToIndex(evt.getPoint()); } } });
@Override public void mouseClicked(MouseEvent e) { if( SwingUtilities.isRightMouseButton(e) ){ @SuppressWarnings("unchecked") JList<PathPrinter> list = (JList<PathPrinter>)e.getSource(); int row = list.locationToIndex(e.getPoint()); list.setSelectedIndex(row); popup.show(list, e.getX(), e.getY()); } }
@Override public void mouseDragged(MouseEvent e) { if (MatchesPanel.getInstance().isEmpty()) return; if (firstMouseEvent1 != null) { e.consume(); int dx = Math.abs(e.getX() - firstMouseEvent1.getX()); int dy = Math.abs(e.getY() - firstMouseEvent1.getY()); //Arbitrarily define a 5-pixel shift as the //official beginning of a drag. if (dx > 5 || dy > 5) { //This is a drag, not a click. JComponent c = (JComponent)e.getSource(); //Tell the transfer handler to initiate the drag. TransferHandler handler = c.getTransferHandler(); handler.exportAsDrag(c, firstMouseEvent1, TransferHandler.COPY); firstMouseEvent1 = null; } } }
@Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { Component componentSource = (Component) e.getSource(); JPopupMenu menu = new JPopupMenu(); for (int position = 0 ; position < MediatorGui.menubar().getMenuView().getMenuComponentCount() ; position++) { // Fix #35348: SerializationException on clone() try { JMenuItem itemMenu = (JMenuItem) SerializationUtils.clone(MediatorGui.menubar().getMenuView().getMenuComponent(position)); menu.add(itemMenu); final int positionFinal = position; itemMenu.addActionListener(actionEvent -> MediatorGui.tabManagers().setSelectedIndex(positionFinal)); } catch (SerializationException ex) { LOGGER.error(ex, ex); } } menu.show(componentSource, e.getX(), e.getY()); menu.setLocation( ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? e.getXOnScreen() - menu.getWidth() : e.getXOnScreen(), e.getYOnScreen() ); } }
@Override public void mouseClicked(MouseEvent e) { Component source = (Component)e.getSource(); if (source instanceof Marker) { ((Marker)source).mouseClicked(e); return; } int line = yToLine(e.getY()); if (line>-1) { try { int offs = textArea.getLineStartOffset(line); textArea.setCaretPosition(offs); } catch (BadLocationException ble) { // Never happens UIManager.getLookAndFeel().provideErrorFeedback(textArea); } } }
@Override public void mouseClicked(MouseEvent e) { if (e.getModifiers() == InputEvent.BUTTON3_MASK) { if (!(e.getSource() instanceof JTable)) { return; } tableComponent = (JTable) e.getSource(); tableComponent.requestFocus(); int nx = e.getX(); if (nx > 500) { nx = nx - popup.getSize().width; } popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height); } } }
table.addMouseListener( new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { JTable source = (JTable)e.getSource(); int row = source.rowAtPoint( e.getPoint() ); int column = source.columnAtPoint( e.getPoint() ); if (! source.isRowSelected(row)) source.changeSelection(row, column, false, false); popup.show(e.getComponent(), e.getX(), e.getY()); } } });
public void showPopup(final MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { JList<ItemList> list = (JList<ItemList>) mouseEvent.getSource(); this.dndList.dropPasteFile( Arrays.asList(importFileDialog.getSelectedFiles()), this.dndList.locationToIndex(mouseEvent.getPoint()) ); list, ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? mouseEvent.getX() - popupMenuList.getWidth() : mouseEvent.getX(), mouseEvent.getY() ); } catch (IllegalComponentStateException e) {
@Override public void mouseClicked(MouseEvent e) { if (e.getModifiers() == InputEvent.BUTTON3_MASK) { if (!(e.getSource() instanceof JList)) { return; } queueList = (JList) e.getSource(); queueListModel = (DefaultListModel) queueList.getModel(); queueList.requestFocus(); int nx = e.getX(); if (nx > 500) { nx = nx - popup.getSize().width; } popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height); } } }
table.addMouseListener( new MouseAdapter() { public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { JTable source = (JTable)e.getSource(); int row = source.rowAtPoint( e.getPoint() ); int column = source.columnAtPoint( e.getPoint() ); if (! source.isRowSelected(row)) source.changeSelection(row, column, false, false); popup.show(e.getComponent(), e.getX(), e.getY()); } } });
public void mouseClicked(MouseEvent evt) { @SuppressWarnings("unchecked") JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); String entryName = (String) list.getModel().getElementAt(index); String[] array = entryName.split("/");
private MouseEvent translateEvent(MouseEvent e) { Dimension stretchedDimensions = client.getStretchedDimensions(); Dimension realDimensions = client.getRealDimensions(); int newX = (int) (e.getX() / (stretchedDimensions.width / realDimensions.getWidth())); int newY = (int) (e.getY() / (stretchedDimensions.height / realDimensions.getHeight())); return new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiersEx(), newX, newY, e.getClickCount(), e.isPopupTrigger(), e.getButton()); } }
if (event instanceof MouseEvent && event.getSource() instanceof Component) { MouseEvent e = (MouseEvent) event; MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this); if (!this.contains(m.getPoint())) { boolean allowedEvent = false; popupComponent = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY()); // show root component (popups creates at root) if (popupComponent != null && popupComponent.getClass().getName().contains("BasicComboPopup")) { popupEvent = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, popupComponent); allowedEvent = true;
@Override public void mouseDragged(MouseEvent e) { if (MatchesPanel.getInstance().isEmpty()) return; if (firstMouseEvent != null) { e.consume(); if(dragNDrop) { if(textField == null) return; if(Point2D.distanceSq(e.getX(), e.getY(), firstMouseEvent.getX(), firstMouseEvent.getY()) > 25) { //do DnD textField.getTransferHandler().exportAsDrag((JComponent) e.getSource(), firstMouseEvent, TransferHandler.COPY); } } else { addHighlight(textField, firstMouseEvent, e); } } } }
public void mouseReleased(MouseEvent e) { if (e.getSource().equals(this.objectJList) && e.isPopupTrigger() && this.objectJList.getSelectedIndex() >= 0) { int i = this.objectJList.locationToIndex(e.getPoint()); this.objectJList.setSelectedIndex(i); this.objectJPopupMenu.show(this.objectJList, e.getX(), e.getY()); } } }
@Override public void mouseDragged(MouseEvent e) { if (MatchesPanel.getInstance().isEmpty()) return; if (firstMouseEvent != null) { e.consume(); JTextField label = ((TreeFromFile) list.getSelectedValue()).getLabel(); if(dragNDrop) { if(label == null) return; if(Point2D.distanceSq(e.getX(), e.getY(), firstMouseEvent.getX(), firstMouseEvent.getY()) > 25) { //do DnD list.getTransferHandler().exportAsDrag((JComponent) e.getSource(), firstMouseEvent, TransferHandler.COPY); } } else { addHighlight(label, firstMouseEvent, e); } } }
public void mouseReleased(MouseEvent e) { if (e.getSource().equals(this.objectJList) && e.isPopupTrigger() && this.objectJList.getSelectedIndex() >= 0) { int i = this.objectJList.locationToIndex(e.getPoint()); this.objectJList.setSelectedIndex(i); this.objectJPopupMenu.show(this.objectJList, e.getX(), e.getY()); } }