List of usage examples for java.awt.event MouseEvent getY
public int getY()
From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.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. ja va 2s .co m */ private void checkSelectionAndPopupMenu(java.awt.event.MouseEvent evt) { int row = eventTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (row == -1) { deselectRows(); } if (evt.isPopupTrigger()) { if (row != -1) { eventTable.setRowSelectionInterval(row, row); } parent.eventPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java
/** * Shows the popup menu when the trigger button (right-click) has been pushed. *///from w ww . j a v a2s. c o m private void checkSelectionAndPopupMenu(java.awt.event.MouseEvent evt) { int row = filterTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (evt.isPopupTrigger()) { if (row != -1) { filterTable.setRowSelectionInterval(row, row); } filterPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:com.jcraft.weirdx.DDXWindowImp.java
private void procPressed(MouseEvent e) { int x = e.getX() + window.x; int y = e.getY() + window.y; oldWindowx = window.x;/*w ww . ja v a2 s.c o m*/ oldWindowy = window.y; XWindow.sprite.hot.x = x; XWindow.sprite.hot.y = y; int mod = e.getModifiers(); if (mod == 0) { mod |= InputEvent.BUTTON1_MASK; } // ????? int state = 0; int detail = 1; if ((mod & InputEvent.BUTTON1_MASK) != 0) detail = 1; if ((mod & InputEvent.BUTTON2_MASK) != 0) detail = 2; if ((mod & InputEvent.BUTTON3_MASK) != 0) detail = 3; if ((mod & InputEvent.SHIFT_MASK) != 0) state |= 1; if ((mod & InputEvent.CTRL_MASK) != 0) state |= 4; // alt -> state|=8; Event.filters[Event.MotionNotify] = Event.PointerMotionMask | Event.ButtonMotionMask | ((Event.Button1Mask >> 1) << detail); event.mkButtonPress(detail, window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 1); try { if (XWindow.grab == null) { if (XWindow.checkDeviceGrabs(event, 0, 1)) { return; } } if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1); } catch (Exception ee) { } if ((mod & InputEvent.BUTTON1_MASK) != 0) { state |= (1 << 8); } if ((mod & InputEvent.BUTTON2_MASK) != 0) { state |= (1 << 9); } if ((mod & InputEvent.BUTTON3_MASK) != 0) { state |= (1 << 10); } // if((mod & InputEvent.SHIFT_MASK)!=0) state|=1; // if((mod & InputEvent.CTRL_MASK)!=0) state|=4; // alt -> state|=8; XWindow.sprite.hot.state = state; }
From source file:op.care.med.structure.PnlMed.java
private void treeMedMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_treeMedMousePressed if (product == null) return;/*from w w w . j av a2s. c o m*/ if (!OPDE.getAppInfo().isAllowedTo(InternalClassACL.MANAGER, internalClassID)) return; if (SwingUtilities.isRightMouseButton(evt)) { // Dieses Popupmenu fr den Table SYSTools.unregisterListeners(menu); menu = new JPopupMenu(); // JMenuItem itemdaf = new JMenuItem("Neue Darreichungsform"); // itemdaf.addActionListener(new java.awt.event.ActionListener() { // public void actionPerformed(java.awt.event.ActionEvent evt) { // btnNeuDAF(evt); // } // }); // menu.add(itemdaf); if (treeMed.getRowForLocation(evt.getX(), evt.getY()) != -1 && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { JMenuItem itemedit = null; JMenuItem itemUPRedit = null; // JMenuItem itemnew = null; // JMenuItem itempack = null; TreePath curPath = treeMed.getPathForLocation(evt.getX(), evt.getY()); final DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) curPath.getLastPathComponent(); treeMed.setSelectionPath(curPath); // final ListElement le = (ListElement) dmtn.getUserObject(); // int nodetype = ((Integer) le.getObject()).intValue(); if (dmtn.getUserObject() instanceof TradeForm) { final TradeForm tradeForm = (TradeForm) dmtn.getUserObject(); itemedit = new JMenuItem(SYSTools.xx("misc.msg.edit")); itemedit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new DlgTradeForm(tradeForm); createTree(); } }); itemUPRedit = new JMenuItem(SYSTools.xx("upreditor.tooltip")); itemUPRedit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new DlgUPREditor(tradeForm, new Closure() { @Override public void execute(Object o) { reload(); } }); } }); itemUPRedit.setEnabled(tradeForm.getDosageForm().isUPRn()); // itempack = new JMenuItem("Neue Verpackung"); // itempack.addActionListener(new java.awt.event.ActionListener() { // public void actionPerformed(java.awt.event.ActionEvent evt) { // MedPackage mypack = new MedPackage(tradeForm); // new DlgPack(OPDE.getMainframe(), "Neu", mypack); //// OPDE.getEMF().getCache().evict(Darreichung.class, darreichung.getID()); // createTree(); // } // }); } else if (dmtn.getUserObject() instanceof MedPackage) { final MedPackage packung = (MedPackage) dmtn.getUserObject(); itemedit = new JMenuItem("Bearbeiten"); itemedit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { new DlgPack(SYSTools.xx("misc.msg.edit"), packung); createTree(); } }); } else if (dmtn.getUserObject() instanceof MedProducts) { itemedit = new JMenuItem("Bearbeiten"); itemedit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DlgProduct dlg = new DlgProduct(SYSTools.xx("misc.msg.edit"), (MedProducts) dmtn.getUserObject()); product = dlg.getProduct(); createTree(); } }); } if (itemedit != null) menu.add(itemedit); if (itemUPRedit != null) menu.add(itemUPRedit); } menu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:Classes.MainForm.java
public void mainFrameMouseDragged(MouseEvent e) {//moving form with mouse int x = this.mainFrame.getLocationOnScreen().x;//main form actual x position int y = this.mainFrame.getLocationOnScreen().y;//main form actual y position this.mainFrame.setLocation(x + (e.getX()) - mouseInitX, y + (e.getY()) - mouseInitY);//moving form to new location of mouse }
From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java
private void makeAttributesTable() { setEventAttributes(null, true);// w w w . j a v a 2 s. com // listen for trigger button and double click to edit channel. eventAttributesTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { if (eventAttributesTable.rowAtPoint(new Point(evt.getX(), evt.getY())) == -1) { return; } if (evt.getClickCount() >= 2) { new ViewContentDialog((String) eventAttributesTable.getModel().getValueAt( eventAttributesTable.getSelectedModelIndex(), ATTRIBUTES_VALUE_COLUMN_NUMBER)); } } }); eventAttributesTable.setSelectionMode(0); // Disable HTML in a column. DefaultTableCellRenderer noHTMLRenderer = new DefaultTableCellRenderer(); noHTMLRenderer.putClientProperty("html.disable", Boolean.TRUE); eventAttributesTable.getColumnExt(ATTRIBUTES_VALUE_COLUMN_NAME).setCellRenderer(noHTMLRenderer); eventAttributesPane.setViewportView(eventAttributesTable); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopTree.java
public DesktopTree() { layout = new MigLayout("flowy, fill, insets 0", "", "[min!][fill]"); panel = new JPanel(layout); topPanel = new JPanel(new BorderLayout()); topPanel.setVisible(false);/*w w w. ja v a2 s .com*/ panel.add(topPanel, "growx"); impl = new JTree(); treeView = new JScrollPane(impl); panel.add(treeView, "grow"); impl.setRootVisible(false); impl.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); impl.setExpandsSelectedPaths(true); impl.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { showPopup(e); } @Override public void mouseReleased(MouseEvent e) { showPopup(e); } private void showPopup(MouseEvent e) { if (e.isPopupTrigger()) { // select row Point p = e.getPoint(); TreePath treePath = impl.getPathForLocation(p.x, p.y); if (treePath != null) { TreeSelectionModel model = impl.getSelectionModel(); model.setSelectionPath(treePath); } // show popup menu createPopupMenu().show(e.getComponent(), e.getX(), e.getY()); } } }); impl.addKeyListener(new KeyAdapter() { protected static final int ENTER_CODE = 10; @Override public void keyPressed(KeyEvent e) { if (ENTER_CODE == e.getKeyCode() && e.getComponent() == DesktopTree.this.getComponent()) { if (enterPressAction != null) { enterPressAction.actionPerform(DesktopTree.this); } else { handleClickAction(); } } } }); }
From source file:edu.ku.brc.af.ui.forms.ResultSetController.java
/** * Creates the UI for the controller./*from w w w.ja v a 2 s . c o m*/ * @param addNewBtn indicates it should include the "Add" (New Object) button * @param addDelBtn indicates it should include Delete button * @param objTitle the title of a single object in the controller (used for building tooltips) */ protected void buildRecordNavBar(final boolean addNewBtn, final boolean addDelBtn, final boolean addSearchBtn, final String objTitle) { String colDef = "p,2dlu,p,2dlu,max(50dlu;p):grow,2dlu,p,2dlu,p" + (addNewBtn ? ",12px,p" : "") + (addDelBtn ? ",2dlu,p" : "") + (addSearchBtn ? ",2dlu,p" : ""); Insets insets = new Insets(1, 1, 1, 1); DefaultFormBuilder rowBuilder = new DefaultFormBuilder(new FormLayout(colDef, "p")); firstBtn = UIHelper.createIconBtn("FirstRec", null, null); prevBtn = UIHelper.createIconBtn("PrevRec", null, null); btnsHash.put(CommandType.Previous, prevBtn); btnsHash.put(CommandType.First, firstBtn); recDisp = createLabel(" "); recDisp.setHorizontalAlignment(SwingConstants.CENTER); recDisp.setOpaque(true); recDisp.setBackground(Color.WHITE); recDisp.setBorder(enabledBorder); recDisp.setFont(recDisp.getFont().deriveFont(recDisp.getFont().getSize2D() - 2)); MouseListener mouseListener = new MouseAdapter() { private boolean showIfPopupTrigger(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { JPopupMenu popupMenu = createPopupMenu(); if (popupMenu != null && popupMenu.getComponentCount() > 0) { popupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); return true; } } return false; } @Override public void mousePressed(MouseEvent mouseEvent) { showIfPopupTrigger(mouseEvent); } @Override public void mouseReleased(MouseEvent mouseEvent) { showIfPopupTrigger(mouseEvent); } /* (non-Javadoc) * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent) */ @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { if (numRecords == 1) { UIRegistry.writeTimedSimpleGlassPaneMsg(getResourceString("OnlyOneRrecordInCon")); } else { showGotoRecDlg(); } } } }; recDisp.addMouseListener(mouseListener); nextBtn = UIHelper.createIconBtn("NextRec", null, null); lastBtn = UIHelper.createIconBtn("LastRec", null, null); btnsHash.put(CommandType.Next, nextBtn); btnsHash.put(CommandType.Last, lastBtn); firstBtn.setToolTipText(createTooltip("GotoFirstRecordTT", objTitle)); prevBtn.setToolTipText(createTooltip("GotoPreviousRecordTT", objTitle)); nextBtn.setToolTipText(createTooltip("GotoNextRecordTT", objTitle)); lastBtn.setToolTipText(createTooltip("GotoLastRecordTT", objTitle)); firstBtn.setOpaque(false); prevBtn.setOpaque(false); nextBtn.setOpaque(false); lastBtn.setOpaque(false); CellConstraints cc = new CellConstraints(); rowBuilder.add(firstBtn, cc.xy(1, 1)); rowBuilder.add(prevBtn, cc.xy(3, 1)); rowBuilder.add(recDisp, cc.xy(5, 1)); rowBuilder.add(nextBtn, cc.xy(7, 1)); rowBuilder.add(lastBtn, cc.xy(9, 1)); int col = 11; if (addNewBtn) { if (false) { newRecBtn = new JButton("+") { public void setEnabled(boolean enable) { //log.debug("newRecBtn - RS: "+ formValidator.getName() + " " + newRecBtn.hashCode() + " "+enable+" isNewObj: "+isNewObj); if (formValidator != null && formValidator.getName() != null && formValidator.getName().equals("Collection Object")) { int x = 0; x++; if (enable) { int y = 0; y++; } } if (enable) { int x = 0; x++; } super.setEnabled(enable); } }; setControlSize(newRecBtn); ActionListener l = new ActionListener() { public void actionPerformed(ActionEvent ae) { for (ResultSetControllerListener rscl : listeners) { rscl.newRecordAdded(); } } }; newRecBtn.addActionListener(l); } else { newRecBtn = UIHelper.createIconBtn("NewRecord", null, new ActionListener() { public void actionPerformed(ActionEvent ae) { for (ResultSetControllerListener rscl : listeners) { rscl.newRecordAdded(); } } }); } newRecBtn.setToolTipText(createTooltip("NewRecordTT", objTitle)); newRecBtn.setEnabled(true); newRecBtn.setMargin(insets); btnsHash.put(CommandType.NewItem, newRecBtn); if (doLayoutBtns) { rowBuilder.add(newRecBtn, cc.xy(col, 1)); col += 2; } } if (addDelBtn) { if (false) { delRecBtn = new JButton("-") { public void setEnabled(boolean enable) { //log.debug("delRecBtn - RS: "+formValidator.getName() + " " + hashCode() + " "+enable); if (formValidator != null && formValidator.getName() != null && formValidator.getName().equals("Permit")) { int x = 0; x++; } if (!enable) { int x = 0; x++; } super.setEnabled(enable); } }; } else { delRecBtn = UIHelper.createIconBtn("DeleteRecord", null, null); } delRecBtn.setToolTipText(createTooltip("DeleteRecordTT", objTitle)); delRecBtn.setMargin(insets); btnsHash.put(CommandType.DelItem, delRecBtn); if (doLayoutBtns) { rowBuilder.add(delRecBtn, cc.xy(col, 1)); col += 2; } } if (addSearchBtn) { searchRecBtn = UIHelper.createIconBtn("Search", IconManager.IconSize.Std16, null, null); searchRecBtn.setToolTipText(createTooltip("SearchForRecordTT", objTitle)); searchRecBtn.setMargin(insets); if (doLayoutBtns) { rowBuilder.add(searchRecBtn, cc.xy(col, 1)); col += 2; } } firstBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { firstRecord(); } }); prevBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { prevRecord(); } }); nextBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { nextRecord(); } }); lastBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { lastRecord(); } }); // Make sure it gets centered rowBuilder.getPanel().setOpaque(false); DefaultFormBuilder outerCenteredPanel = new DefaultFormBuilder(new FormLayout("c:p:g", "p")); outerCenteredPanel.add(rowBuilder.getPanel(), cc.xy(1, 1)); panel = outerCenteredPanel.getPanel(); panel.setOpaque(false); }
From source file:org.jax.maanova.test.gui.VolcanoPlotPanel.java
private void mouseMoved(MouseEvent e) { if (this.showTooltip) { Point2D chartPoint = this.chartPanel.toChartPoint(e.getPoint()); // find the nearest probe XYProbeData xyProbeData = this.getXYData(); double[][] xyData = new double[][] { xyProbeData.getXData(), xyProbeData.getYData() }; int nearestDotIndex = PlotUtil.getNearestDataIndex(xyData, chartPoint.getX(), chartPoint.getY()); if (nearestDotIndex == -1) { this.clearProbePopup(); } else {//from w w w .ja v a2 s.c o m Point2D probeJava2DCoord = this.getJava2DCoordinates(xyData, nearestDotIndex); double java2DDist = probeJava2DCoord.distance(e.getX(), e.getY()); // is the probe close enough to be worth showing (in pixel distance) if (java2DDist <= PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS * 2) { this.showProbePopup(xyProbeData.getProbeIndices()[nearestDotIndex], e.getX(), e.getY()); } else { this.clearProbePopup(); } } } }
From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java
/** * Shows the popup menu when the trigger button (right-click) has been pushed. *///from w ww .java2s. c om private void checkSelectionAndPopupMenu(java.awt.event.MouseEvent evt) { int row = transformerTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (evt.isPopupTrigger()) { if (row != -1) { transformerTable.setRowSelectionInterval(row, row); } transformerPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } }