Example usage for java.awt.event MouseEvent getY

List of usage examples for java.awt.event MouseEvent getY

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getY.

Prototype

public int getY() 

Source Link

Document

Returns the vertical y position of the event relative to the source component.

Usage

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * Shows the popup menu when the trigger button (right-click) has been pushed. Deselects the
 * rows if no row was selected.//  w  w  w.  ja va2 s .  c  o  m
 */
private void checkAttachmentSelectionAndPopupMenu(java.awt.event.MouseEvent evt) {
    int row = attachmentTable.rowAtPoint(new Point(evt.getX(), evt.getY()));
    if (row == -1) {
        deselectAttachmentRows();
    }

    if (evt.isPopupTrigger()) {
        if (row != -1) {
            attachmentTable.setRowSelectionInterval(row, row);
        }
        attachmentPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
    }
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * Shows the popup menu when the trigger button (right-click) has been pushed. Deselects the
 * rows if no row was selected./*from  w  w  w.j  a va 2 s  .  c o  m*/
 */
private void checkMessageSelectionAndPopupMenu(java.awt.event.MouseEvent evt) {
    int row = messageTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY()));
    if (row == -1) {
        deselectRows();
    }

    if (evt.isPopupTrigger()) {
        if (row != -1) {
            messageTreeTable.setRowSelectionInterval(row, row);
        }
        parent.messagePopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
    }
}

From source file:net.rptools.maptool.client.ui.MapToolFrame.java

private AssetPanel createAssetPanel() {
    final AssetPanel panel = new AssetPanel("mainAssetPanel");
    panel.addImagePanelMouseListener(new MouseAdapter() {
        @Override/*from ww  w  .j  a v  a2 s . c om*/
        public void mouseReleased(MouseEvent e) {
            // TODO use for real popup logic
            //            if (SwingUtilities.isLeftMouseButton(e)) {
            //               if (e.getClickCount() == 2) {
            //
            //                  List<Object> idList = panel.getSelectedIds();
            //                  if (idList == null || idList.size() == 0) {
            //                     return;
            //                  }
            //
            //                  final int index = (Integer) idList.get(0);
            //                  createZone(panel.getAsset(index));
            //               }
            //            }
            if (SwingUtilities.isRightMouseButton(e) && MapTool.getPlayer().isGM()) {
                List<Object> idList = panel.getSelectedIds();
                if (idList == null || idList.size() == 0) {
                    return;
                }
                final int index = (Integer) idList.get(0);

                JPopupMenu menu = new JPopupMenu();
                menu.add(new JMenuItem(new AbstractAction() {
                    {
                        putValue(NAME, I18N.getText("action.newMap"));
                    }

                    public void actionPerformed(ActionEvent e) {
                        createZone(panel.getAsset(index));
                    }
                }));
                panel.showImagePanelPopup(menu, e.getX(), e.getY());
            }
        }

        private void createZone(Asset asset) {
            Zone zone = ZoneFactory.createZone();
            zone.setName(asset.getName());
            BufferedImage image = ImageManager.getImageAndWait(asset.getId());
            if (image.getWidth() < 200 || image.getHeight() < 200) {
                zone.setBackgroundPaint(new DrawableTexturePaint(asset));
            } else {
                zone.setMapAsset(asset.getId());
                zone.setBackgroundPaint(new DrawableColorPaint(Color.black));
            }
            MapPropertiesDialog newMapDialog = new MapPropertiesDialog(MapTool.getFrame());
            newMapDialog.setZone(zone);
            newMapDialog.setVisible(true);

            if (newMapDialog.getStatus() == MapPropertiesDialog.Status.OK) {
                MapTool.addZone(zone);
            }
        }
    });
    return panel;
}

From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java

/**
 * Sets the properties and adds the listeners for the Mappings Table. No data is loaded at this
 * point.//  ww  w.jav  a 2 s.c om
 */
private void makeMappingsTable() {
    updateMappingsTable(null, true);

    // listen for trigger button and double click to edit channel.
    mappingsTable.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            if (mappingsTable.rowAtPoint(new Point(evt.getX(), evt.getY())) == -1) {
                return;
            }

            if (evt.getClickCount() >= 2) {
                new ViewContentDialog((String) mappingsTable.getModel()
                        .getValueAt(mappingsTable.convertRowIndexToModel(mappingsTable.getSelectedRow()), 2));
            }
        }
    });

    mappingsTable.setSelectionMode(0);
    mappingsTable.getColumnExt(SCOPE_COLUMN_NAME).setMinWidth(UIConstants.MIN_WIDTH);
    mappingsTable.getColumnExt(SCOPE_COLUMN_NAME).setMaxWidth(UIConstants.MAX_WIDTH);

    // Disable HTML in a column.
    DefaultTableCellRenderer noHTMLRenderer = new DefaultTableCellRenderer();
    noHTMLRenderer.putClientProperty("html.disable", Boolean.TRUE);
    mappingsTable.getColumnExt(VALUE_COLUMN_NAME).setCellRenderer(noHTMLRenderer);

    mappingsPane.setViewportView(mappingsTable);
}

From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java

/**
 * Creates a new {@link AttributeStatisticsPanel} instance. Before displaying the panel, an
 * {@link AbstractAttributeStatisticsModel} should be set via
 * {@link #setModel(AbstractAttributeStatisticsModel, boolean)}.
 *
 *///w  w  w . j  av  a2s  .co m
public AttributeStatisticsPanel() {
    listOfChartPanels = new LinkedList<>();

    // create listener which listens for hovering/enlarge mouse events on this panel
    enlargeAndHoverAndPopupMouseAdapter = new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent e) {
            // only popup trigger for popup menu
            if (e.isPopupTrigger()) {
                handlePopup(e);
            }

            // only left mouse button to enlarge
            if (!SwingUtilities.isLeftMouseButton(e)) {
                return;
            }

            // little hack so hovering over the details button does not remove the hover effect
            // (because MouseExited is called)
            // but clicking the button is still possible and does not enlarge the panel
            if (e.getSource() instanceof JButton) {
                ((JButton) e.getSource()).doClick();
                return;
            }

            // change enlarged status
            if (getModel() != null) {
                getModel().setEnlarged(!getModel().isEnlarged());
            }
        }

        @Override
        public void mouseExited(final MouseEvent e) {
            if (SwingTools.isMouseEventExitedToChildComponents(AttributeStatisticsPanel.this, e)) {
                // we are still hovering over the ASP, just a child component
                return;
            }
            hovered = false;
            repaint();
        }

        @Override
        public void mouseEntered(final MouseEvent e) {
            hovered = true;
            repaint();
        }

        @Override
        public void mouseReleased(final MouseEvent e) {
            if (e.isPopupTrigger()) {
                handlePopup(e);
            }
        }

        /**
         * Handles the popup click event.
         *
         * @param e
         */
        private void handlePopup(final MouseEvent e) {
            if (model.getAttribute().isNumerical()) {
                popupAttributeNumericalStatPanel.show(e.getComponent(), e.getX(), e.getY());
            } else if (model.getAttribute().isNominal()) {
                popupAttributeNominalStatPanel.show(e.getComponent(), e.getX(), e.getY());
            } else if (model.getAttribute().isDateTime()) {
                popupAttributeDateTimeStatPanel.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    };

    // create listener which listens for AttributeStatisticsEvents on the model
    listener = new AttributeStatisticsEventListener() {

        @Override
        public void modelChanged(final AttributeStatisticsEvent e) {
            switch (e.getEventType()) {
            case ALTERNATING_CHANGED:
                repaint();
                break;
            case ENLARGED_CHANGED:
                updateCharts();
                updateVisibilityOfChartPanels();
                if (AttributeStatisticsPanel.this.model.getAttribute().isNominal()) {
                    displayNominalValues();
                }
                break;
            case SHOW_CONSTRUCTION_CHANGED:
                panelStatsConstruction.setVisible(model.isShowConstruction());
                break;
            case STATISTICS_CHANGED:
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        AbstractAttributeStatisticsModel model = AttributeStatisticsPanel.this.model;
                        if (model.getAttribute().isNumerical()) {
                            updateNumericalElements(model);
                        } else if (model.getAttribute().isNominal()) {
                            updateNominalElements(model);
                        } else {
                            updateDateTimeElements(model);
                        }
                    }

                });
                break;
            default:
            }
        }
    };

    initGUI();
}

From source file:GUI.MainWindow.java

private void handleAffectedHosts(MouseEvent evt) {

    Object obj = this.VulnTree.getLastSelectedPathComponent();
    if (obj == null) {
        return;/*w  w w . j a  v  a2s .c  om*/
    }

    int row = VulnAffectedHostsTable.getSelectedRow();
    if (row == -1) // No vulns selected
    {
        // Setup the context menu as required
        EditHostname.setEnabled(false);
        DeleteHost.setEnabled(false);
    } else { // A vuln is selected
        // Setup the context menu as required
        EditHostname.setEnabled(true);
        DeleteHost.setEnabled(true);
    }

    if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
        // this was a double click on  the try
        showNotesForSpecificHost();
    } else if (evt.getButton() == MouseEvent.BUTTON3) {

        VulnAffectedHostsContextMenu.show(VulnAffectedHostsTable, evt.getX(), evt.getY());
    }
}

From source file:gdt.jgui.entity.webset.JWeblinkEditor.java

private void showPasswordMenu(MouseEvent e) {
    try {//from  w  ww. j a  v a2s.  c  o  m
        JPopupMenu passwordMenu = new JPopupMenu();
        JMenuItem copyItem = new JMenuItem("Copy");
        passwordMenu.add(copyItem);
        copyItem.setHorizontalTextPosition(JMenuItem.RIGHT);
        copyItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    StringSelection stringSelection = new StringSelection(passwordField.getText());
                    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                    clipboard.setContents(stringSelection, JWeblinkEditor.this);
                } catch (Exception ee) {
                    Logger.getLogger(getClass().getName()).info(ee.toString());
                }
            }
        });
        JMenuItem encodeItem = new JMenuItem("Encrypt/decrypt");
        passwordMenu.add(encodeItem);
        encodeItem.setHorizontalTextPosition(JMenuItem.RIGHT);
        encodeItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    save();
                    JTextEncrypter te = new JTextEncrypter();
                    String teLocator$ = te.getLocator();
                    teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$);
                    teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, passwordField.getText());
                    teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT_TITLE, nameField.getText());
                    String weLocator$ = JWeblinkEditor.this.getLocator();
                    weLocator$ = Locator.append(weLocator$, BaseHandler.HANDLER_METHOD, "response");
                    weLocator$ = Locator.append(weLocator$, JRequester.REQUESTER_ACTION,
                            ACTION_ENCODE_PASSWORD);
                    teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                            Locator.compressText(weLocator$));
                    JConsoleHandler.execute(console, teLocator$);
                } catch (Exception ee) {
                    Logger.getLogger(getClass().getName()).info(ee.toString());
                }
            }
        });
        passwordMenu.show(e.getComponent(), e.getX(), e.getY());
    } catch (Exception ee) {
        Logger.getLogger(getClass().getName()).severe(ee.toString());
    }
}

From source file:com.isti.traceview.common.TraceViewChartPanel.java

/**
 * Handles a 'mouse dragged' event.//from   w ww  . j  a  v  a  2  s .c  o m
 * 
 * @param e
 *            the mouse event.
 */
public void mouseDragged(MouseEvent e) {
    // if the popup menu has already been triggered, then ignore dragging...
    if (this.popup != null && this.popup.isShowing()) {
        return;
    }
    // if no initial zoom point was set, ignore dragging...
    if (this.zoomPoint == null) {
        return;
    }
    Graphics2D g2 = (Graphics2D) getGraphics();

    // Erase the previous zoom rectangle (if any)...
    drawZoomRectangle(g2);

    boolean hZoom = false;
    boolean vZoom = false;
    if (this.orientation == PlotOrientation.HORIZONTAL) {
        hZoom = this.rangeZoomable;
        vZoom = this.domainZoomable;
    } else {
        hZoom = this.domainZoomable;
        vZoom = this.rangeZoomable;
    }
    Rectangle2D scaledDataArea = getScreenDataArea((int) this.zoomPoint.getX(), (int) this.zoomPoint.getY());
    if (hZoom && vZoom) {
        // selected rectangle shouldn't extend outside the data area...
        double xmax = Math.min(e.getX(), scaledDataArea.getMaxX());
        double ymax = Math.min(e.getY(), scaledDataArea.getMaxY());
        this.zoomRectangle = new Rectangle2D.Double(this.zoomPoint.getX(), this.zoomPoint.getY(),
                xmax - this.zoomPoint.getX(), ymax - this.zoomPoint.getY());
    } else if (hZoom) {
        double xmax = Math.min(e.getX(), scaledDataArea.getMaxX());
        this.zoomRectangle = new Rectangle2D.Double(this.zoomPoint.getX(), scaledDataArea.getMinY(),
                xmax - this.zoomPoint.getX(), scaledDataArea.getHeight());
    } else if (vZoom) {
        double ymax = Math.min(e.getY(), scaledDataArea.getMaxY());
        this.zoomRectangle = new Rectangle2D.Double(scaledDataArea.getMinX(), this.zoomPoint.getY(),
                scaledDataArea.getWidth(), ymax - this.zoomPoint.getY());
    }

    // Draw the new zoom rectangle...
    drawZoomRectangle(g2);
    g2.dispose();
}

From source file:net.sf.jabref.gui.maintable.MainTableSelectionListener.java

/**
 * Process popup trigger events occurring on an icon cell in the table. Show a menu where the user can choose which
 * external resource to open for the entry. If no relevant external resources exist, let the normal popup trigger
 * handler do its thing instead./*from   ww w. j  av  a  2s.co  m*/
 *
 * @param e The mouse event defining this popup trigger.
 * @param row The row where the event occurred.
 * @param column the MainTableColumn associated with this table cell.
 */
private void showIconRightClickMenu(MouseEvent e, int row, MainTableColumn column) {
    BibEntry entry = tableRows.get(row);
    JPopupMenu menu = new JPopupMenu();
    boolean showDefaultPopup = true;

    // See if this is a simple file link field, or if it is a file-list
    // field that can specify a list of links:
    if (!column.getBibtexFields().isEmpty()) {
        for (String field : column.getBibtexFields()) {
            if (FieldName.FILE.equals(field)) {
                // We use a FileListTableModel to parse the field content:
                FileListTableModel fileList = new FileListTableModel();
                entry.getFieldOptional(field).ifPresent(fileList::setContent);
                for (int i = 0; i < fileList.getRowCount(); i++) {
                    FileListEntry flEntry = fileList.getEntry(i);
                    if (column.isFileFilter()
                            && (!flEntry.type.get().getName().equalsIgnoreCase(column.getColumnName()))) {
                        continue;
                    }
                    String description = flEntry.description;
                    if ((description == null) || (description.trim().isEmpty())) {
                        description = flEntry.link;
                    }
                    menu.add(new ExternalFileMenuItem(panel.frame(), entry, description, flEntry.link,
                            flEntry.type.get().getIcon(), panel.getBibDatabaseContext(), flEntry.type));
                    showDefaultPopup = false;
                }
            } else {
                if (SpecialFieldsUtils.isSpecialField(column.getColumnName())) {
                    // full pop should be shown as left click already shows short popup
                    showDefaultPopup = true;
                } else {
                    if (entry.hasField(field)) {
                        String content = entry.getField(field);
                        Icon icon;
                        JLabel iconLabel = GUIGlobals.getTableIcon(field);
                        if (iconLabel == null) {
                            icon = IconTheme.JabRefIcon.FILE.getIcon();
                        } else {
                            icon = iconLabel.getIcon();
                        }
                        menu.add(new ExternalFileMenuItem(panel.frame(), entry, content, content, icon,
                                panel.getBibDatabaseContext(), field));
                        showDefaultPopup = false;
                    }
                }
            }
        }
        if (showDefaultPopup) {
            processPopupTrigger(e, row);
        } else {
            menu.show(table, e.getX(), e.getY());
        }
    }
}

From source file:com.jcraft.weirdx.DDXWindowImpSwing.java

public void mouseEntered(MouseEvent e) {

    if (window != null && window.getFrame() != null) {
        java.awt.Window frame = window.getFrame();
        if ((frame instanceof java.awt.Frame) && frame == e.getSource()) {
            try {
                if (window.isRealized()) {
                    XWindow.setInputFocus(window.client, window.id, 1, (int) System.currentTimeMillis(), false);
                }//from   w  w  w  . j  a  v a 2  s.  co  m
            } catch (Exception ee) {
                LOG.error(ee);
            }
            return;
        }
    }

    String str = CopyPaste.getString();
    if (!CopyPaste.isOwner() && str != null) {
        synchronized (window.screen.root) {
            Property p = window.screen.root.getProperty();
            while (p != null) {
                if (p.propertyName == 9)
                    break;
                p = p.next;
            }
            if (p != null) {
                p.data = str.getBytes();
                p.size = p.data.length;
            }
        }

        Selection sel = Selection.getSelection(1); // PRIMARY
        if (sel != null && sel.client != null) {
            int time = (int) System.currentTimeMillis();
            Event event = new Event();
            event.mkSelectionClear(time, sel.wid, sel.selection);
            try {
                sel.client.sendEvent(event, 1, Event.NoEventMask, Event.NoEventMask, null);
            } catch (Exception ee) {
                //System.out.println(ee);
            }
            ;
            sel.window = window.screen.root;
            sel.wid = window.screen.root.id;
            sel.lastTimeChanged = time;
            sel.client = null;
        }
        CopyPaste.setString(str);
    }

    if (window.id == window.screen.rootId) {
        return;
    }

    if (window.isMapped()) {
        requestFocus();
        XWindow.focus.win = window.id;
    }

    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();
    int state = 0;
    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        state |= (1 << 8);
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        state |= (1 << 9);
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        state |= (1 << 10);
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    Client client = window.client;
    if (client == null || client == serverClient)
        return;

    event.mkEnterNotify(0, // Ancestor
            window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal
            0x1 | 0x02 // focus|same-screen
    );
    try {
        XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}