Example usage for java.awt.event MouseEvent isPopupTrigger

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

Introduction

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

Prototype

public boolean isPopupTrigger() 

Source Link

Document

Returns whether or not this mouse event is the popup menu trigger event for the platform.

Usage

From source file:de.mendelson.comm.as2.client.AS2Gui.java

@Override
public void mouseClicked(MouseEvent evt) {
    if (evt.isPopupTrigger() || evt.isMetaDown()) {
        if (evt.getSource().equals(this.jTableMessageOverview)) {
            this.jPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
        }//www  .j a va 2 s  . co m
    }
}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

@Override
public void mousePressed(final MouseEvent e) {
    final boolean ctrlPressed = (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0;
    if (this.application == null) {
        if (!ctrlPressed && e.isPopupTrigger()) {
            final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint());
            onPopup(e.getPoint(), hexNumber);
        } else {/* w  w w . j a v  a 2 s  . c  o m*/
            switch (e.getButton()) {
            case MouseEvent.BUTTON1: {
                if (selectedToolType != null && this.selectedLayer != null) {
                    addedUndoStep(new HexFieldLayer[] { this.selectedLayer });
                    final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint());
                    useCurrentToolAtPosition(hexNumber);
                }
            }
                break;
            case MouseEvent.BUTTON3: {
                if (ctrlPressed) {
                    this.dragging = true;
                    this.hexMapPanelDesktop.initDrag(e.getPoint());
                }
            }
                break;
            }
        }
    } else if (!ctrlPressed && e.isPopupTrigger() && this.application.allowPopupTrigger()) {
        this.application.processHexAction(this.hexMapPanel, e, HexAction.POPUP_TRIGGER,
                this.hexMapPanel.getHexPosition(e.getPoint()));
    } else if (e.getButton() == MouseEvent.BUTTON3) {
        this.dragging = true;
        this.hexMapPanelDesktop.initDrag(e.getPoint());
    }
}

From source file:com.mirth.connect.client.ui.DashboardPanel.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 v a2  s . c o m
 */
private void checkSelectionAndPopupMenu(MouseEvent event) {
    TreePath path = dashboardTable.getPathForLocation(event.getX(), event.getY());

    /*
     * On mouse events we don't need to update the dashboard panel plugins. They will already
     * have been updated because of the ListSelectionEvent, and multiple mouse events will enter
     * here (as many as three, one pressed and two released) so we would basically be doing four
     * times the work.
     */
    if (path == null) {
        deselectRows(false);
    } else {
        updatePopupMenu(false);
    }

    if (event.isPopupTrigger()) {
        TreeSelectionModel selectionModel = dashboardTable.getTreeSelectionModel();

        if (!selectionModel.isPathSelected(path)) {
            deselectRows(false);
            selectionModel.addSelectionPath(path);
        }

        parent.dashboardPopupMenu.show(event.getComponent(), event.getX(), event.getY());
    }
}

From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java

private void jList1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MousePressed
    if (evt.isPopupTrigger()) {
        jList1.setSelectedIndex(jList1.locationToIndex(evt.getPoint()));
        jPopupMenu1.show(jList1, evt.getX(), evt.getY());
    }//from w  ww .j a va 2s.com
}

From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java

private void jList1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseReleased
    if (evt.isPopupTrigger()) {
        jList1.setSelectedIndex(jList1.locationToIndex(evt.getPoint()));
        jPopupMenu1.show(jList1, evt.getX(), evt.getY());
    }/*from   w ww .  j  a  v a 2 s .  c om*/
}

From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java

private void sedsTableMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sedsTableMousePressed
    if (evt.isPopupTrigger()) {
        JTable source = (JTable) evt.getSource();
        int row = source.rowAtPoint(evt.getPoint());
        int column = source.columnAtPoint(evt.getPoint());

        if (!source.isRowSelected(row))
            source.changeSelection(row, column, false, false);

        sedsTable.changeSelection(row, column, false, false);

        jPopupMenu2.show(evt.getComponent(), evt.getX(), evt.getY());
    }/*from w ww  .ja  v  a  2 s  .  c  om*/
}

From source file:corelyzer.ui.CorelyzerGLCanvas.java

public void mouseReleased(final MouseEvent e) {
    // For mouse right-click or Ctrl-Left-Click
    if (e.isPopupTrigger()) {
        this.handleRightMouseClick(e);

        return;/*w  w  w.ja  v a  2 s.  c o  m*/
    }

    if (e.getButton() == MouseEvent.BUTTON1) {
        if (canvasMode == CorelyzerApp.APP_CLAST_MODE) {
            this.handleClastMouseReleased(e);
        } else if (canvasMode == CorelyzerApp.APP_CUT_MODE) {
            this.handleCutMouseReleased(e);
        }
    }

    prePos.setLocation(0, 0);
    canvas.setCursor(Cursor.getDefaultCursor());

    CorelyzerApp.getApp().updateGLWindows();
}

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

@SuppressWarnings("unused")
public void mouseDragged(MouseEvent e) {

    if (threeButton) {
        if (threeBstate != s) {
            if (threeBstate == sp) {
                procPressed(threeBPressed);
                threeBPressed = null;/*  w ww . j a va  2 s  .c  om*/
                threeBstate = s;
            } else if (threeBstate == spp) {
                e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                        (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                                | InputEvent.BUTTON2_MASK,
                        e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
            } else if (threeBstate == sppr) {
                return;
            }
        }
    }

    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();

    // button 1 -> 16
    // button 2 -> 8
    // button 3 -> 4
    // shift -> 1
    // control -> 2
    // alt -> 12 ?? 

    int state = 0;
    int detail = 0;

    if ((mod & InputEvent.BUTTON1_MASK) != 0) {
        state |= (1 << 8);
        detail = 1;
    }
    if ((mod & InputEvent.BUTTON2_MASK) != 0) {
        state |= (1 << 9);
        detail = 2;
    }
    if ((mod & InputEvent.BUTTON3_MASK) != 0) {
        state |= (1 << 10);
        detail = 3;
    }
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    XWindow.sprite.hot.state = state;

    px = x;
    py = y;

    event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/
            XWindow.sprite.win.id, 0, px, py, e.getX(), e.getY(), state, 1);

    try {
        if (!XWindow.checkMotion(event, window)) {
            return;
        }
        event.mkMotionNotify(1, window.screen.rootId, /*window.id,*/
                XWindow.sprite.win.id, 0, px, py, px - XWindow.sprite.win.x, py - XWindow.sprite.win.y,
                //e.getX(),
                //e.getY(),
                state, 1);
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(XWindow.sprite.win, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

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

public void mousePressed(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == s) {
            threeBPressed = e;//from w ww  .  j  a  v  a 2 s  . c  o  m
            threeBstate = sp;
            return;
        }
        if (threeBstate == sp
        //       || threeBstate==sppr
        ) {
            threeBPressed = null;
            threeBstate = spp;
            e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                    (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                            | InputEvent.BUTTON2_MASK,
                    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
        }
    }

    procPressed(e);
}

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

@SuppressWarnings("unused")
public void mouseDragged(MouseEvent e) {

    if (threeButton) {
        if (threeBstate != s) {
            if (threeBstate == sp) {
                procPressed(threeBPressed);
                threeBPressed = null;//from   w  w w . j  a  va  2 s  . c o  m
                threeBstate = s;
            } else if (threeBstate == spp) {
                e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                        (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                                | InputEvent.BUTTON2_MASK,
                        e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
            } else if (threeBstate == sppr) {
                return;
            }
        }
    }

    if (window == null)
        return;

    // calc abs cursor position use old window position for calculation
    // as mouseDragged (if you use Panel) delivers its coordinates relative to the position after mousepressed
    // UPDATE: this was a bug of the IBM JDK
    //    int x=e.getX()+oldwindowx;
    //    int y=e.getY()+oldwindowy;
    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    // set new drag position (absolute)
    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();

    // button 1 -> 16
    // button 2 -> 8
    // button 3 -> 4
    // shift -> 1
    // control -> 2
    // alt -> 12 ?? 

    int state = 0;
    int detail = 0;

    if ((mod & InputEvent.BUTTON1_MASK) != 0) {
        state |= (1 << 8);
        detail = 1;
    }
    if ((mod & InputEvent.BUTTON2_MASK) != 0) {
        state |= (1 << 9);
        detail = 2;
    }
    if ((mod & InputEvent.BUTTON3_MASK) != 0) {
        state |= (1 << 10);
        detail = 3;
    }
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    XWindow.sprite.hot.state = state;

    px = x;
    py = y;

    event.mkMotionNotify(1, window.screen.rootId, XWindow.sprite.win.id, 0, px, py, e.getX(), e.getY(), state,
            1);

    try {
        if (!XWindow.checkMotion(event, window)) {
            return;
        }
        event.mkMotionNotify(1, window.screen.rootId, XWindow.sprite.win.id, 0, px, py,
                px - XWindow.sprite.win.x, py - XWindow.sprite.win.y, state, 1);
        if (XWindow.grab != null) {
            XWindow.sendGrabbedEvent(event, false, 1);
        } else {
            XWindow.sendDeviceEvent(XWindow.sprite.win, event, XWindow.grab, null, 1);
        }
    } catch (Exception ee) {
    }
}