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:de.tbuchloh.kiskis.gui.treeview.TreeView.java

/**
 * @param treeContext//from  w w w  .  ja v a2 s.  co  m
 */
public TreeView(final JPopupMenu treeContext) {
    final GroupNode root = new GroupNode();
    root.setModelNode(new Group());
    _treeModel = new DefaultTreeModel(root);
    setModel(_treeModel);

    this.setEditable(true);
    this.setCellRenderer(new SpecialNodeCellRenderer());
    this.setCellEditor(new NameCellEditor());
    this.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                LOG.debug("Context Menu invoked!"); //$NON-NLS-1$
                treeContext.show(TreeView.this, e.getX(), e.getY());
            }
        }
    });
    setDragEnabled(true);
    setAutoscrolls(true);
}

From source file:org.adempiere.apps.graph.PerformanceIndicator.java

/**
*    Init Graph Display/*from w w  w . jav  a 2 s. c  o  m*/
*  Kinamo (pelgrim)
*/
private void init() {
    chartPanel = new ChartPanel(createChart(), //chart
            false, //boolean properties
            false, // boolean save
            false, //boolean print
            false, //boolean zoom
            true //boolean tooltips
    );
    chartPanel.setPreferredSize(indicatordimension);

    chartPanel.addChartMouseListener(new org.jfree.chart.ChartMouseListener() {
        public void chartMouseClicked(org.jfree.chart.ChartMouseEvent e) {
            //plot p = (MeterPlot) e.getSource();
            MouseEvent me = e.getTrigger();
            if (SwingUtilities.isLeftMouseButton(me) && me.getClickCount() > 1)
                fireActionPerformed(me);
            if (SwingUtilities.isRightMouseButton(me))
                popupMenu.show((Component) me.getSource(), me.getX(), me.getY());
        }

        public void chartMouseMoved(org.jfree.chart.ChartMouseEvent e) {

        }
    });

    this.add(chartPanel, BorderLayout.NORTH);
    this.setMinimumSize(paneldimension);
    this.setMaximumSize(paneldimension);
    //---------------------------------------------

    invalidate();
}

From source file:de.tbuchloh.kiskis.gui.widgets.PasswordElement.java

private void initCreatePopup() {
    _pwdCreateMenu = new JPopupMenu();
    final JMenuItem secure = new JMenuItem(M.getString("secure_item")); //$NON-NLS-1$
    secure.addActionListener(new PasswordActionListener(PasswordFactory.SECURE));
    _pwdCreateMenu.add(secure);//from w w w  .  j ava  2  s.co m

    final JMenuItem human = new JMenuItem(M.getString("human_readable_item")); //$NON-NLS-1$
    human.addActionListener(new PasswordActionListener(PasswordFactory.HUMAN_READABLE));
    _pwdCreateMenu.add(human);

    final JMenuItem template = new JMenuItem(M.createAction(this, "onCreateByTemplate"));
    _pwdCreateMenu.add(template);

    _specialActionsMenu = new JPopupMenu();
    _specialActionsMenu.add(M.createAction(this, "onCopyToClipboard"));

    _pwdField.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(final MouseEvent e) {
            if (e.getButton() != MouseEvent.BUTTON3) {
                return;
            }
            final int x = e.getX(); // _pwdField.getWidth()
            // - _specialActionsMenu.getWidth();
            final int y = e.getY();

            LOG.debug("Show context menu x=" + x + ", y=" + y);
            _specialActionsMenu.show(_pwdField, x, y);
        }
    });
}

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

public void mousePressed(MouseEvent e) {
    if (isReadOnly())
        return;/*from  w  w w .j ava  2s . co m*/
    if (SwingUtilities.isRightMouseButton(e)) {
        if (popup != null)
            popup.show(getGraph(), e.getX(), e.getY());
    } else {
        if (selected == null)
            return;
        if (isMove()) {
            selection = false;
            x0 = e.getX();
            y0 = e.getY();
            drawBarShadow(x0, y0, true);
        } else if (isDirectAction()) {
            executeAction(e.getX(), e.getY());
            state = NOTHING_SELECTED;
            //select(e.getX(),e.getY()); //TODO commented to avoid second action when spliting
        }
    }
}

From source file:dotaSoundEditor.Controls.EditorPanel.java

protected void attachDoubleClickListenerToTree() {
    MouseListener ml = new MouseAdapter() {
        @Override/*  ww  w.  j ava  2  s .  c om*/
        public void mousePressed(MouseEvent e) {
            int selRow = currentTree.getRowForLocation(e.getX(), e.getY());
            TreePath selPath = currentTree.getPathForLocation(e.getX(), e.getY());
            if (selRow != -1 && ((DefaultMutableTreeNode) selPath.getLastPathComponent()).isLeaf()) {
                if (e.getClickCount() == 2) {
                    playSelectedTreeSound(selPath, Paths.get(vpkPath));
                }
            }
        }
    };
    currentTree.addMouseListener(ml);
}

From source file:edu.purdue.cc.bionet.ui.HeatMap.java

/**
 * The mouseClicked method of the MouseListener interface.
 * //from w w  w .j  av  a2  s .  c o  m
 * @param event The MouseEvent which triggered this action.
 */
public void mouseClicked(MouseEvent event) {
    if (mapPosition.contains(event.getPoint())) {
        Correlation clicked = this.getCorrelationFromPoint(new Point(event.getX(), event.getY()));
        if (clicked != null && this.range.contains(Math.abs(clicked.getValue(this.correlationMethod)))) {
            this.fireGraphMouseEvent(clicked, event);
        }
    }

}

From source file:Main.java

public Main() {
    setSize(300, 300);/*www.  java2  s  .co m*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JTextArea textArea = new JTextArea();
    textArea.setText("Click Me!");

    textArea.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.NOBUTTON) {
                textArea.setText("No button clicked...");
            } else if (e.getButton() == MouseEvent.BUTTON1) {
                textArea.setText("Button 1 clicked...");
            } else if (e.getButton() == MouseEvent.BUTTON2) {
                textArea.setText("Button 2 clicked...");
            } else if (e.getButton() == MouseEvent.BUTTON3) {
                textArea.setText("Button 3 clicked...");
            }

            System.out.println("Number of click: " + e.getClickCount());
            System.out.println("Click position (X, Y):  " + e.getX() + ", " + e.getY());
        }
    });

    getContentPane().add(textArea);
}

From source file:com.ivli.roim.controls.ChartControl.java

@Override
public void mouseDragged(MouseEvent e) {
    final XYPlot plot = getChart().getXYPlot();

    if (null != iEntity) {
        moveTo(plot.getRangeAxis().java2DToValue(e.getY(), getChartRenderingInfo().getPlotInfo().getDataArea(),
                plot.getRangeAxisEdge()));
    }//from w  ww.  j  av  a 2s  .c  om
    if (null != iMarker) {
        double domainX = plot.getDomainAxis().java2DToValue(e.getX(), getScreenDataArea(),
                plot.getDomainAxisEdge());
        iMarker.setValue(domainX);
    } else
        super.mouseDragged(e);
}

From source file:com.univocity.app.swing.DataAnalysisWindow.java

private void addPopupMenuToTable(DaoTable daoTable, boolean isSourceTable) {
    String engineName = isSourceTable ? config.getSourceEngineName() : config.getDestinationEngineName();

    if (engineName == null) {
        return;// w  ww  .  j av  a 2 s  .com
    }

    final JTable table = daoTable.getDataTable();
    final JPopupMenu menu = new JPopupMenu();
    menu.add(newJMenuItem("Disable updates", daoTable, engineName, false, false));
    menu.add(newJMenuItem("Enable updates", daoTable, engineName, true, false));
    menu.add(new JSeparator());
    menu.add(newJMenuItem("Disable updates on all rows", daoTable, engineName, false, true));
    menu.add(newJMenuItem("Enable updates on all rows", daoTable, engineName, true, true));

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                int rowNumber = table.rowAtPoint(e.getPoint());
                if (rowNumber != -1) {
                    table.getSelectionModel().setSelectionInterval(rowNumber, rowNumber);
                    menu.show(table, e.getX(), e.getY());
                }
            }
        };
    });
}

From source file:de.codesourcery.eve.skills.ui.components.impl.ItemChooserComponent.java

@Override
protected JPanel createPanelHook() {

    tree.setRootVisible(false);/*from  w  ww. j  av  a2 s . c  om*/
    tree.setCellRenderer(treeRenderer);

    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() != 2 || e.isPopupTrigger()) {
                return;
            }

            final TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
            final ITreeNode node = (ITreeNode) path.getLastPathComponent();

            if (node.getValue() instanceof InventoryType) {
                final InventoryType selectedItem = (InventoryType) node.getValue();
                selectedItemsModel.addItem(selectedItem);
                if (selectionMode == SelectionMode.SINGLE_SELECTION) {
                    okButtonClicked();
                } else if (selectionMode == SelectionMode.MULTIPLE_SELECTION) {
                    // ok
                } else {
                    throw new RuntimeException("Unhandled mode " + selectionMode);
                }
            }
        }
    });

    tree.addTreeWillExpandListener(new TreeWillExpandListener() {

        @Override
        public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
        }

        @Override
        public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
            handleTreeExpansion(event);
        }
    });

    final JScrollPane pane = new JScrollPane(tree);
    pane.setPreferredSize(new Dimension(400, 400));

    final JPanel result = new JPanel();
    result.setLayout(new GridBagLayout());

    switch (selectionMode) {
    case SINGLE_SELECTION:
        result.add(pane, constraints().useRemainingSpace().resizeBoth().end());
        break;
    case MULTIPLE_SELECTION:
        result.add(pane, constraints(0, 0).useRelativeWidth().resizeBoth().end());
        result.add(createListViewPanel(), constraints(1, 0).useRemainingWidth().resizeBoth().end());
        break;
    default:
        throw new RuntimeException("Unhandled selection mode" + selectionMode);
    }

    return result;
}