Example usage for java.awt.event MouseEvent MOUSE_CLICKED

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

Introduction

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

Prototype

int MOUSE_CLICKED

To view the source code for java.awt.event MouseEvent MOUSE_CLICKED.

Click Source Link

Document

The "mouse clicked" event.

Usage

From source file:org.kalypso.mt.input.MTMouseInput.java

@Override
public void processAction() {
    if (invocCounter++ % 6 == 0 || eventQueue.isEmpty())
        return;// w  ww  .j  a  va2s . co  m

    // purge all events waiting if mouse is blocked
    if (m_mouseBlocks > 0) {
        eventQueue.clear();
        return;
    }

    // otherwise process events
    final long time = System.currentTimeMillis();
    while (!eventQueue.isEmpty()) {
        final long dist = time - eventQueue.peekFirst().timestamp;

        if (dist > 200) {
            // ok, process this one
            final MTMouseEventData e = eventQueue.pollFirst();
            switch (e.event.getID()) {
            case MouseEvent.MOUSE_PRESSED:
                this.mousePressed(e.event);
                break;
            case MouseEvent.MOUSE_RELEASED:
                this.mouseReleased(e.event);
                break;
            case MouseEvent.MOUSE_CLICKED:
                this.mouseClicked(e.event);
                break;
            case MouseEvent.MOUSE_DRAGGED:
                this.mouseDragged(e.event);
                break;
            case MouseEvent.MOUSE_MOVED:
                this.mouseMoved(e.event);
                break;
            }

        } else {
            break;
        }

    }

}

From source file:org.nuclos.client.ui.collect.searcheditor.SearchEditorController.java

/**
 * event: a mouse event occured on a node in the <code>view</code>
 * @param selPath the path of the node where the mouse event occured.
 * @param ev//w w w .  j  av  a 2 s  .  c  om
 */
private void mouseEventOnNode(TreePath selPath, MouseEvent ev) {
    final SearchConditionTreeNode node = (SearchConditionTreeNode) selPath.getLastPathComponent();
    final JTree tree = (JTree) ev.getComponent();

    // select the node:
    tree.setSelectionPath(selPath);

    if (ev.isPopupTrigger()) {
        // show popup menu:
        final JPopupMenu popupMenu = this.getPopupMenu(node, tree);
        if (popupMenu != null) {
            popupMenu.show(ev.getComponent(), ev.getX(), ev.getY());
        }
    } else if (ev.getID() == MouseEvent.MOUSE_CLICKED) {
        if (ev.getButton() == MouseEvent.BUTTON1) {
            if (ev.getClickCount() == 2) {
                if (this.clctfproviderfactory == null) {
                    throw new IllegalStateException(
                            "No CollectableFieldsProviderFactory was defined for the search editor.");
                }
                // perform the node's default action:
                final Action actDefault = node.getDefaultTreeNodeAction(tree, this.clcteRoot,
                        this.clctfproviderfactory, this.additionalFields);
                if (actDefault != null) {
                    actDefault.actionPerformed(null);
                }
            }
        }
    }
}