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:org.jax.maanova.plot.MaanovaChartPanel.java

private void myMouseDragged(MouseEvent e) {
    if (this.dragRectangle != null) {
        this.dragRectangle.width = e.getX() - this.dragRectangle.x;
        this.dragRectangle.height = e.getY() - this.dragRectangle.y;

        this.repaint();
    }/*from www  .j  a  v  a  2 s . c o m*/
}

From source file:com.igormaznitsa.sciareto.ui.tree.ExplorerTree.java

public ExplorerTree(@Nonnull final Context context) {
      super();/*w w w  . java  2s  .co m*/
      this.projectTree = new DnDTree();
      this.context = context;
      this.projectTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
      this.projectTree.setDropMode(DropMode.ON);

      this.projectTree.setEditable(true);

      ToolTipManager.sharedInstance().registerComponent(this.projectTree);

      this.projectTree.setCellRenderer(new TreeCellRenderer());
      this.projectTree.setModel(new NodeProjectGroup(context, "."));
      this.projectTree.setRootVisible(false);
      this.setViewportView(this.projectTree);

      this.projectTree.addMouseListener(new MouseAdapter() {
          @Override
          public void mouseClicked(@Nonnull final MouseEvent e) {
              if (e.getClickCount() > 1) {
                  final int selRow = projectTree.getRowForLocation(e.getX(), e.getY());
                  final TreePath selPath = projectTree.getPathForLocation(e.getX(), e.getY());
                  if (selRow >= 0) {
                      final NodeFileOrFolder node = (NodeFileOrFolder) selPath.getLastPathComponent();
                      if (node != null && node.isLeaf()) {
                          final File file = node.makeFileForNode();
                          if (file != null && !context.openFileAsTab(file)) {
                              UiUtils.openInSystemViewer(file);
                          }
                      }
                  }
              }
          }

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

          @Override
          public void mousePressed(@Nonnull final MouseEvent e) {
              if (e.isPopupTrigger()) {
                  processPopup(e);
              }
          }

          private void processPopup(@Nonnull final MouseEvent e) {
              final TreePath selPath = projectTree.getPathForLocation(e.getX(), e.getY());
              if (selPath != null) {
                  projectTree.setSelectionPath(selPath);
                  final Object last = selPath.getLastPathComponent();
                  if (last instanceof NodeFileOrFolder) {
                      makePopupMenu((NodeFileOrFolder) last).show(e.getComponent(), e.getX(), e.getY());
                  }
              }
          }

      });
  }

From source file:MainGUI.java

private void bkgPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_bkgPanelMouseClicked
    for (CButton c : ((BKGPanel) bkgPanel).getButtons()) {
        if (c.isContained(evt.getX(), evt.getY())) {
            if (c.text.equals("Play")) {
                final MainGUI main = this;
                SwingUtilities.invokeLater(new Runnable() {
                    @Override/*from  w w w .j  av  a 2  s.c om*/
                    public void run() {
                        QuestionGUI gui = new QuestionGUI(main,
                                Question.generateQuestionSet(main.getDifficulty(), 20), username);
                        gui.setVisible(true);
                    }
                });
            } else if (c.text.equals("Check Stats")) {
                try {
                    if (stats != null && stats.isValid()) {
                        return;
                    }
                    stats = new UserHistoryGUI(username);
                    stats.setVisible(true);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            } else if (c.text.equals("Options")) {
                opt.setVisible(true);
            } else if (c.text.equals("Facebook Connect")) {

            }
        }
    }
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mousePressed(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
        if (this.coElutionRegion == null) {
            shifted = true;/*from   ww  w  . ja v  a  2 s  .  c om*/
            Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY());
            if (screenDataArea != null) {
                this.coElutionStart = getPointInRectangle(e.getX(), e.getY(), screenDataArea);
            } else {
                this.coElutionStart = null;
            }
        }
    } else {
        _cp.mousePressed(e);
    }
}

From source file:PopUpColorMenu.java

public PopUpColorMenu() {
    JFrame frame = new JFrame();

    final JPopupMenu colorMenu = new JPopupMenu("Color");
    colorMenu.add(makeMenuItem("Red"));
    colorMenu.add(makeMenuItem("Green"));
    colorMenu.add(makeMenuItem("Blue"));

    MouseListener mouseListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            checkPopup(e);//from  www  .  jav  a 2 s  .c o  m
        }

        public void mouseClicked(MouseEvent e) {
            checkPopup(e);
        }

        public void mouseReleased(MouseEvent e) {
            checkPopup(e);
        }

        private void checkPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                selectedComponent = e.getComponent();
                colorMenu.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    };

    frame.setLayout(new FlowLayout());
    JButton button = new JButton("Uno");
    button.addMouseListener(mouseListener);
    frame.add(button);
    button = new JButton("Due");
    button.addMouseListener(mouseListener);
    frame.add(button);
    button = new JButton("Tre");
    button.addMouseListener(mouseListener);
    frame.add(button);

    frame.getContentPane().addMouseListener(mouseListener);

    frame.setSize(200, 50);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:ObjectInspector.java

@Override
public String getToolTipText(MouseEvent me) {
    TreePath pathForLocation = getPathForLocation(me.getX(), me.getY());

    if (pathForLocation != null) {
        Object lastPathComponent = pathForLocation.getLastPathComponent();
        if (lastPathComponent instanceof ObjectNode) {
            ObjectNode on = (ObjectNode) lastPathComponent;

            return on.tooltip;
        }/*  w  w  w . j  a  va 2s  . co m*/
    }

    return null;
}

From source file:com.projity.pm.graphic.graph.GraphInteractor.java

public void mouseMoved(MouseEvent e) {
    if (isReadOnly())
        return;
    select(e.getX(), e.getY());
}

From source file:EventTestPane.java

/**
 * Display mouse moved and dragged mouse event. Note that MouseEvent is the
 * only event type that has two methods, two EventListener interfaces and
 * two adapter classes to handle two distinct categories of events. Also, as
 * seen in init(), mouse motion events must be requested separately from
 * other mouse event types./*from w w  w.j a  v a 2s. c  o m*/
 */
public void processMouseMotionEvent(MouseEvent e) {
    String type = null;
    switch (e.getID()) {
    case MouseEvent.MOUSE_MOVED:
        type = "MOUSE_MOVED";
        break;
    case MouseEvent.MOUSE_DRAGGED:
        type = "MOUSE_DRAGGED";
        break;
    }
    showLine(mousemods(e) + type + ": [" + e.getX() + "," + e.getY() + "] " + "num clicks = "
            + e.getClickCount() + (e.isPopupTrigger() ? "; is popup trigger" : ""));
}

From source file:au.org.ala.delta.editor.ui.CharacterTree.java

@Override
public String getToolTipText(MouseEvent event) {
    TreePath path = getClosestPathForLocation(event.getX(), event.getY());
    if (path != null) {
        Object node = path.getLastPathComponent();
        if (node instanceof CharacterTreeNode) {
            CharacterTreeNode chNode = (CharacterTreeNode) node;
            String desc = chNode.getCharacter().getDescription();
            int width = getGraphics().getFontMetrics(getFont()).stringWidth(desc);
            if (width > getParent().getWidth() - 70) {
                if (width > 400) {
                    return String.format("<html><body style=\"width: %dpx;\">%s</body></html>", 400,
                            StringEscapeUtils.escapeHtml(desc));
                } else {
                    return desc;
                }//w w  w . j  a  v  a2  s .  co  m
            }
        }
    }
    return null;
}

From source file:eu.europa.ec.markt.dss.applet.view.validationpolicy.EditView.java

private void registerMouseListener(final JTree tree) {

    MouseListener mouseAdapter = new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            if (mouseEvent.getButton() == MouseEvent.BUTTON3) {
                final int selectedRow = tree.getRowForLocation(mouseEvent.getX(), mouseEvent.getY());
                final TreePath selectedPath = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY());
                if (selectedRow != -1) {
                    final XmlDomAdapterNode clickedItem = (XmlDomAdapterNode) selectedPath
                            .getLastPathComponent();
                    final boolean isLeaf = tree.getModel().isLeaf(selectedPath.getLastPathComponent());
                    // Do nothing on root element
                    if (selectedPath.getPathCount() > 1) {
                        // find the allowed actions, to know if a popup menu should be displayed and the content of the popup menu + action handlers
                        if (clickedItem.node instanceof Element) {
                            nodeActionAdd(mouseEvent, selectedRow, selectedPath, clickedItem, tree);
                        } else if (isLeaf) {
                            valueLeafActionEdit(mouseEvent, selectedPath, clickedItem, tree);
                        }//from ww w. j  av a  2s . co m
                    }
                }
            }
        }
    };
    tree.addMouseListener(mouseAdapter);
}