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:es.emergya.ui.gis.ControlPanel.java

public ControlPanel(final CustomMapView view) {
    super(new FlowLayout(FlowLayout.LEADING, 12, 0));
    this.view = view;
    // Posicion: panel con un label de icono y un textfield
    JPanel posPanel = new JPanel();
    posPanel.setOpaque(true);/*ww w . j av  a  2 s  .  c  om*/
    posPanel.setVisible(true);
    JLabel mouseLocIcon = new JLabel(LogicConstants.getIcon("map_icon_coordenadas"));
    posPanel.add(mouseLocIcon);
    final JTextField posField = new JTextField(15);
    posField.setEditable(false);
    posField.setBorder(null);
    posField.setForeground(UIManager.getColor("Label.foreground"));
    posField.setFont(UIManager.getFont("Label.font"));
    posPanel.add(posField);
    view.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent e) {
            LatLon ll = ((ICustomMapView) e.getSource()).getLatLon(e.getX(), e.getY());
            String position = "";
            String format = LogicConstants.get("FORMATO_COORDENADAS_MAPA", "UTM");
            if (format.equals(LogicConstants.COORD_UTM)) {
                UTM u = new UTM(LogicConstants.getInt("ZONA_UTM"));
                EastNorth en = u.latlon2eastNorth(ll);
                position = String.format("x: %.1f y: %.1f", en.getX(), en.getY());
            } else {
                position = String.format("Lat: %.4f Lon: %.4f", ll.lat(), ll.lon());
            }

            posField.setText(position);
            validate();
        }

        @Override
        public void mouseDragged(MouseEvent e) {
        }
    });
    posPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    add(posPanel);

    // Panel de centrado: label, desplegable y parte cambiante
    JPanel centerPanel = new JPanel();
    centerPanel.add(new JLabel(i18n.getString("map.centerIn")));
    centerOptions = new JComboBox(new String[] { i18n.getString("map.street"), i18n.getString("map.resource"),
            i18n.getString("map.incidence"), i18n.getString("map.location") });
    centerPanel.add(centerOptions);

    centerData = new JPanel(new CardLayout());
    centerPanel.add(centerData);

    JPanel centerStreet = new JPanel();
    street = new JTextField(30);
    street.setName(i18n.getString("map.street"));
    autocompleteKeyListener = new AutocompleteKeyListener(street);
    street.addKeyListener(autocompleteKeyListener);
    street.addActionListener(this);
    centerStreet.add(street);
    centerData.add(centerStreet, i18n.getString("map.street"));

    JPanel centerResource = new JPanel();
    resources = new JComboBox(avaliableResources);
    resources.setName(i18n.getString("map.resource"));
    resources.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    resources.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            isComboResourcesShowing = true;
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            isComboResourcesShowing = false;
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // view.repaint();
        }
    });
    centerResource.add(resources);
    centerData.add(centerResource, i18n.getString("map.resource"));

    centerResource = new JPanel();
    incidences = new JComboBox(avaliableIncidences);
    incidences.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    incidences.setName(i18n.getString("map.incidence"));
    incidences.addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            isComboIncidencesShowing = true;
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            isComboIncidencesShowing = false;
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {

        }
    });
    centerResource.add(incidences);
    centerData.add(centerResource, i18n.getString("map.incidence"));

    JPanel centerLocation = new JPanel();
    cx = new JTextField(10);
    cx.setName("x");
    cx.addActionListener(this);
    centerLocation.add(cx);
    cy = new JTextField(10);
    cy.setName("y");
    cy.addActionListener(this);
    centerLocation.add(cy);
    centerData.add(centerLocation, i18n.getString("map.location"));

    centerOptions.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            ((CardLayout) centerData.getLayout()).show(centerData, (String) e.getItem());
        }
    });

    JButton centerButton = new JButton(i18n.getString("map.center"));
    centerButton.addActionListener(this);
    centerPanel.add(centerButton);
    add(centerPanel);

}

From source file:MouseTest.java

public MouseTest() {
    super();/*  w  w w. j  av a 2s. c o  m*/

    final JPopupMenu pop = new JPopupMenu();
    pop.add(new JMenuItem("Cut"));
    pop.add(new JMenuItem("Copy"));
    pop.add(new JMenuItem("Paste"));
    pop.addSeparator();
    pop.add(new JMenuItem("Select All"));
    pop.setInvoker(this);

    MouseListener popup = new MouseListener() {
        public void mouseClicked(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        private void showPopup(MouseEvent e) {
            pop.show(e.getComponent(), e.getX(), e.getY());
        }
    };
    addMouseListener(popup);

    MouseListener drawing1 = new MouseListener() {
        public void mouseClicked(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
            color = Color.RED;
            startX = endX = e.getX();
            startY = endY = e.getY();
            repaint();
        }

        public void mouseReleased(MouseEvent e) {
            color = Color.BLACK;
            repaint();
        }
    };
    addMouseListener(drawing1);

    MouseMotionListener drawing2 = new MouseMotionListener() {
        public void mouseDragged(MouseEvent e) {
            endX = e.getX();
            endY = e.getY();
            repaint();
        }

        public void mouseMoved(MouseEvent e) {
        }
    };
    addMouseMotionListener(drawing2);

}

From source file:io.bibleget.BibleGetHelp.java

private void jTree1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree1MouseClicked
    // TODO add your handling code here:
    int tp = jTree1.getRowForLocation(evt.getX(), evt.getY());
    //System.out.println(tp);
    if (tp != -1 && tp < 4) {
        switch (tp) {
        case 0:/*from   www.ja v a 2s.  c  o m*/
            jTextPane2.setDocument(doc);
            jTextPane2.setText(HTMLStr0);
            jTextPane2.setCaretPosition(0);
            break;
        case 1:
            jTextPane2.setDocument(doc);
            jTextPane2.setText(HTMLStr1);
            jTextPane2.setCaretPosition(0);
            break;
        case 2:
            jTextPane2.setDocument(doc);
            jTextPane2.setText(HTMLStr2);
            jTextPane2.setCaretPosition(0);
            break;
        case 3:
            String curLang = Locale.getDefault().getDisplayLanguage().toUpperCase();
            //System.out.println(curLang);
            jTextPane2.setDocument(doc);
            jTextPane2.setText(MessageFormat.format(HTMLStr3, booksAndAbbreviations.get(curLang), curLang));
            jTextPane2.setCaretPosition(0);
            break;
        default:
            jTextPane2.setDocument(doc);
            jTextPane2.setText(HTMLStr0);
            jTextPane2.setCaretPosition(0);
        }
    } else if (tp > 3) {
        TreePath treePath = jTree1.getPathForLocation(evt.getX(), evt.getY());
        String curPath = treePath.getLastPathComponent().toString().toUpperCase(Locale.ENGLISH);
        //System.out.println(curPath);
        if (booksAndAbbreviations.get(curPath) != null) {
            jTextPane2.setDocument(doc);
            jTextPane2.setText(MessageFormat.format(HTMLStr3, booksAndAbbreviations.get(curPath), curPath));
            jTextPane2.setCaretPosition(0);
        }
    }
    //jTextPane2.setText("<span>"+tp+"</span>");
    //else
    //jtf.setText("");
}

From source file:JavaXWin.java

public void mousePressed(MouseEvent e) {
    m_dragging = true;//from www. j a va2s. c  o m
    m_dragX = e.getX();
    m_dragY = e.getY();
    m_lowerY = m_resizeComponent.getY() + m_resizeComponent.getHeight();
    if (e.getX() < CORNER) {
        m_mode = NORTHWEST;
    } else if (e.getX() > getWidth() - CORNER) {
        m_mode = NORTHEAST;
    } else {
        m_mode = NORTH;
    }
}

From source file:com.quinsoft.zeidon.objectbrowser.EntitySquare.java

private void doPop(MouseEvent e) {
    EntityPopupMenu menu = new EntityPopupMenu();
    menu.show(e.getComponent(), e.getX(), e.getY());
}

From source file:com.ctsim.dmi.MainFrame.java

private void viewPanelMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_viewPanelMouseMoved
    this.x = evt.getX();
    this.y = evt.getY();
}

From source file:com.wwidesigner.gui.StudyView.java

@Override
protected void initializeComponents() {
    // create file tree
    tree = new JTree() {
        @Override/*from  w w  w  . j a  va2s  . co  m*/
        public String getToolTipText(MouseEvent e) {
            String tip = null;
            TreePath path = tree.getPathForLocation(e.getX(), e.getY());
            if (path != null) {
                if (path.getPathCount() == 3) // it is a leaf
                {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                    if (node instanceof TreeNodeWithToolTips) {
                        tip = ((TreeNodeWithToolTips) node).getToolTip();
                    }
                }
            }
            return tip == null ? getToolTipText() : tip;
        }
    };
    // Show tooltips for the Study view, and let them persist for 8 seconds.
    ToolTipManager.sharedInstance().registerComponent(tree);
    ToolTipManager.sharedInstance().setDismissDelay(8000);
    // If a Study view node doesn't fit in the pane, expand it when hovering
    // over it.
    ExpandedTipUtils.install(tree);
    tree.setRootVisible(false);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            TreePath path = tree.getPathForLocation(e.getX(), e.getY());
            if (path != null) {
                if (path.getPathCount() == 3) // it is a leaf
                {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                    DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent();
                    String category = (String) parentNode.getUserObject();
                    study.setCategorySelection(category, (String) node.getUserObject());
                    if (StudyModel.INSTRUMENT_CATEGORY_ID.equals(category)
                            || StudyModel.TUNING_CATEGORY_ID.equals(category)) {
                        try {
                            study.validHoleCount();
                        } catch (Exception ex) {
                            showException(ex);
                        }
                    }
                }
                updateView();
            }
        }
    });
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(225, 100));
    add(scrollPane);

    Preferences myPreferences = getApplication().getPreferences();
    String modelName = myPreferences.get(OptimizationPreferences.STUDY_MODEL_OPT,
            OptimizationPreferences.NAF_STUDY_NAME);
    setStudyModel(modelName);
    study.setPreferences(myPreferences);

    getApplication().getEventManager().subscribe(WIDesigner.FILE_OPENED_EVENT_ID, this);
    getApplication().getEventManager().subscribe(WIDesigner.FILE_CLOSED_EVENT_ID, this);
    getApplication().getEventManager().subscribe(WIDesigner.FILE_SAVED_EVENT_ID, this);
    getApplication().getEventManager().subscribe(WIDesigner.WINDOW_RENAMED_EVENT_ID, this);
}

From source file:com.ctsim.dmi.MainFrame.java

private void viewPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_viewPanelMouseClicked
    click_x = evt.getX();/*w  ww  .  j  ava 2s  . c o  m*/
    click_y = evt.getY();

    checkClickObject();
}

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

public CharacterTree() {

    setToggleClickCount(0);// w  w w  .ja  v a2 s. c  o  m
    _characterListBehaviour = new CharacterListBehaviour();
    _stateListBehaviour = new StateListBehaviour();

    ToolTipManager.sharedInstance().registerComponent(this);

    addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            if (_doubleProcessingMouseEvent) {
                return;
            }
            if (!isEditing()) {
                int selectedRow = getClosestRowForLocation(e.getX(), e.getY());

                if ((selectedRow >= 0) && (e.getClickCount() == 2) && SwingUtilities.isLeftMouseButton(e)) {
                    Action action = getActionMap().get(SELECTION_ACTION_KEY);
                    if (action != null) {
                        action.actionPerformed(new ActionEvent(this, -1, ""));
                    }
                }
            }
        }
    });

    addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {

            TreePath selection = e.getNewLeadSelectionPath();
            if (selection != null) {
                Object lastComponent = selection.getLastPathComponent();
                if (lastComponent instanceof DefaultMutableTreeNode) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) lastComponent;

                    if (node.isLeaf()) {
                        CharacterTree.super.setTransferHandler(_stateTransferHandler);
                    } else {
                        CharacterTree.super.setTransferHandler(_characterTransferHandler);
                    }
                }
            }
        }
    });

    ActionMap actionMap = Application.getInstance().getContext().getActionMap(this);

    javax.swing.Action find = actionMap.get("find");
    if (find != null) {
        getActionMap().put("find", find);
    }

    javax.swing.Action findNext = actionMap.get("findNext");
    if (findNext != null) {
        getActionMap().put("findNext", findNext);
    }

    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.CTRL_MASK), SELECTION_ACTION_KEY);

}

From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java

/**
 * {@inheritDoc}/*w  ww . j  a va 2 s. c o  m*/
 */
@Override
public void actionPerformed(final ActionEvent aE) {
    JPanel newPanel = new JPanel(new GridLayout(2, 2));

    newPanel.add(new JLabel("GUID:"));
    final JTextField disabledIDInput = new JTextField(myAccount.getId());
    final JPopupMenu accountIDPopupMenu = createAccountIDPopupMenu();
    disabledIDInput.setEditable(false);
    disabledIDInput.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(final MouseEvent arg0) {
            if (arg0.isPopupTrigger()) {
                accountIDPopupMenu.show(disabledIDInput, arg0.getX(), arg0.getY());
            }
        }

        @Override
        public void mousePressed(final MouseEvent arg0) {
            if (arg0.isPopupTrigger()) {
                accountIDPopupMenu.show(disabledIDInput, arg0.getX(), arg0.getY());
            }
        }

    });
    newPanel.add(disabledIDInput);

    newPanel.add(new JLabel("name:"));
    final JTextField nameInput = new JTextField(myAccount.getName());
    nameInput.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent aE) {
            myAccount.setName(nameInput.getText());
        }

    });
    newPanel.add(nameInput);

    myFrame = new JFrame(myAccount.getName());
    myFrame.getContentPane().setLayout(new BorderLayout());
    myFrame.getContentPane().add(newPanel, BorderLayout.NORTH);
    myFrame.getContentPane().add(getButtonsPanel(), BorderLayout.SOUTH);

    myFrame.getContentPane().add(getMySettingsPanel(), BorderLayout.CENTER);
    myFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    myFrame.pack();
    myFrame.setVisible(true);
}