List of usage examples for java.awt.event MouseEvent getPoint
public Point getPoint()
From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java
/** * Required for mouselistener/*from w ww. j av a2 s . co m*/ * * @param e * MouseEvent */ public void mouseDragged(MouseEvent e) { Point p = e.getPoint(); if (dcOptionPanel.getMouseMode().equals(ST_DRAG)) { int x2 = p4.x - (p.x - p3.x); int y2 = p4.y - (p.y - p3.y); if (x2 < 0) x2 = 0; if (y2 < 0) y2 = 0; dca.setScrollBarPosition(new Point(x2, y2)); } else { p2 = e.getPoint(); repaint(); } }
From source file:com.github.fritaly.dualcommander.DirectoryBrowser.java
@Override public void mouseClicked(MouseEvent e) { if (e.getSource() == table) { if (e.getClickCount() == 2) { // Only react to double clicks final List<File> selection = getSelection(); if (selection.size() == 1) { final File file = selection.iterator().next(); if (file.isDirectory()) { // Change to the clicked directory setDirectory(file);//from w w w . jav a 2 s . c o m } else { try { // View the selected file new ProcessBuilder(preferences.getViewFileCommand(), file.getAbsolutePath()).start(); } catch (IOException e1) { logger.error("Error when viewing file", e1); } } } } } else if (e.getSource() == table.getTableHeader()) { final int columnIndex = table.convertColumnIndexToModel(table.columnAtPoint(e.getPoint())); if (columnIndex >= 0) { // React to clicks on column headers and sort the entries accordingly switch (columnIndex) { case 0: tableModel.setSortCriteria(SortCriteria.TYPE); break; case 1: tableModel.setSortCriteria(SortCriteria.NAME); break; case 2: tableModel.setSortCriteria(SortCriteria.SIZE); break; case 3: tableModel.setSortCriteria(SortCriteria.LAST_UPDATE); break; default: throw new UnsupportedOperationException("Unsupported column index: " + columnIndex); } } } }
From source file:org.yccheok.jstock.gui.NewBuyTransactionJDialog.java
private MouseListener getJFormattedTextFieldMouseListener() { MouseListener ml = new MouseAdapter() { @Override/*from w w w .java2s . c om*/ public void mousePressed(final MouseEvent e) { if (e.getClickCount() == 2) { // Ignore double click. return; } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JTextField tf = (JTextField) e.getSource(); int offset = tf.viewToModel(e.getPoint()); tf.setCaretPosition(offset); } }); } }; return ml; }
From source file:net.sf.jabref.gui.groups.GroupSelector.java
private void definePopup() { // These key bindings are just to have the shortcuts displayed // in the popup menu. The actual keystroke processing is in // BasePanel (entryTable.addKeyListener(...)). groupsContextMenu.add(editGroupPopupAction); groupsContextMenu.add(addGroupPopupAction); groupsContextMenu.add(addSubgroupPopupAction); groupsContextMenu.addSeparator();/*from w w w. j av a2s . c o m*/ groupsContextMenu.add(removeGroupAndSubgroupsPopupAction); groupsContextMenu.add(removeGroupKeepSubgroupsPopupAction); groupsContextMenu.add(removeSubgroupsPopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(expandSubtreePopupAction); groupsContextMenu.add(collapseSubtreePopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(moveSubmenu); sortSubmenu.add(sortDirectSubgroupsPopupAction); sortSubmenu.add(sortAllSubgroupsPopupAction); groupsContextMenu.add(sortSubmenu); moveSubmenu.add(moveNodeUpPopupAction); moveSubmenu.add(moveNodeDownPopupAction); moveSubmenu.add(moveNodeLeftPopupAction); moveSubmenu.add(moveNodeRightPopupAction); groupsContextMenu.addSeparator(); groupsContextMenu.add(addToGroup); groupsContextMenu.add(moveToGroup); groupsContextMenu.add(removeFromGroup); groupsTree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showPopup(e); } } @Override public void mouseClicked(MouseEvent e) { TreePath path = groupsTree.getPathForLocation(e.getPoint().x, e.getPoint().y); if (path == null) { return; } GroupTreeNodeViewModel node = (GroupTreeNodeViewModel) path.getLastPathComponent(); // the root node is "AllEntries" and cannot be edited if (node.getNode().isRoot()) { return; } if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)) { // edit editGroupAction.actionPerformed(null); // dummy event } else if ((e.getClickCount() == 1) && (e.getButton() == MouseEvent.BUTTON1)) { annotationEvent(node); } } }); // be sure to remove a possible border highlight when the popup menu // disappears groupsContextMenu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { // nothing to do } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { groupsTree.setHighlightBorderCell(null); } @Override public void popupMenuCanceled(PopupMenuEvent e) { groupsTree.setHighlightBorderCell(null); } }); }
From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java
public void mouseReleased(MouseEvent e) { if (dcOptionPanel.getMouseMode().equals(ST_ZOOMIN)) { clicked = false;//from w w w . ja va 2 s . co m p2 = e.getPoint(); setViewportZoomIn(); dca.getOverviewPanel().setDrawBox(true); dca.getOverviewPanel().repaint(); } }
From source file:nl.detoren.ijsco.ui.Mainscreen.java
public JPanel createDeelnemersPanel() { JPanel panel = new JPanel(false); panel.setBackground(Color.BLACK); //panel.setLayout(new GridLayout(1, 0)); panel.setLayout(new BorderLayout()); JPanel innerPanel = new JPanel(); JLabel lbAanwezig = new JLabel("Deelnemers: "); innerPanel.add(lbAanwezig, BorderLayout.NORTH); tfAanwezig = new JLabel(Integer.toString(status.deelnemers.aantalAanwezig()), 10); innerPanel.add(tfAanwezig, BorderLayout.NORTH); //innerPanel.setLayout(new GridLayout(1, 0)); innerPanel.add(new JLabel("Naam:"), BorderLayout.NORTH); JTextField deelnemer = new JTextField(15); ArrayList<String> words = new ArrayList<>(); if (status.OSBOSpelers != null) { for (Speler s : status.OSBOSpelers.values()) { words.add(s.getNaam().trim()); words.add(Integer.toString(s.getKnsbnummer())); }// ww w . j a v a 2 s . co m } @SuppressWarnings("unused") Suggesties suggesties = new Suggesties(deelnemer, this, words, 2); innerPanel.add(deelnemer, BorderLayout.NORTH); deelnemer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { actieVoegSpelerToe(deelnemer.getText().trim()); deelnemer.setText(""); } }); JButton btVoegToe = new JButton("Voeg toe"); btVoegToe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { actieVoegSpelerToe(deelnemer.getText().trim()); deelnemer.setText(""); } }); innerPanel.add(btVoegToe); panel.add(innerPanel); // panel_deelnemers.add(new JLabel("Deelnemers IJSCO toernooi")); deelnemersModel = new DeelnemersModel(panel, status.deelnemers); JTable deelnemersTabel = new JTable(deelnemersModel) { private static final long serialVersionUID = -8293073016982337108L; @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); DeelnemersModel model = (DeelnemersModel) getModel(); // Tooltip if (c instanceof JComponent) { ((JComponent) c) .setToolTipText(model.getToolTip(convertRowIndexToModel(row), column).toString()); } // Alternate row color if (!isRowSelected(row)) { c.setBackground(row % 2 == 0 ? Color.WHITE : Color.LIGHT_GRAY); } // Highlight overruled entries if (status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam() || status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam()) { c.setForeground(Color.BLUE); } else { c.setForeground(Color.BLACK); } return c; } }; deelnemersTabel.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { status.groepen = null; status.schemas = null; status.schema = null; groepenText.setText(""); schemaModel.setSchemas(null); schemaModel.fireTableDataChanged(); if (status.deelnemers != null && tfAanwezig != null) { tfAanwezig.setText(Integer.toString(status.deelnemers.aantalAanwezig())); } panel.repaint(); } }); deelnemersTabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { logger.log(Level.INFO, "MouseEvent on table fired, type : " + e.toString()); logger.log(Level.INFO, "Popup trigger? : " + e.isPopupTrigger()); if (e.isPopupTrigger()) { int row = deelnemersTabel.rowAtPoint(e.getPoint()); JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Bewerk speler"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.log(Level.INFO, "Bewerk Speler : " + deelnemersTabel.convertRowIndexToModel(row)); Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row)); BewerkSpelerDialoog rd = new BewerkSpelerDialoog(new JFrame(), "Bewerk Speler", s, deelnemersModel); rd.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { System.out.println("closing..."); } }); rd.setVisible(true); } }); popup.add(menuItem); menuItem = new JMenuItem("Verwijder Speler"); popup.add(menuItem); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.log(Level.INFO, "Verwijder Speler : " + deelnemersTabel.convertRowIndexToModel(row)); Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row)); status.deelnemers.remove(s); deelnemersModel.fireTableDataChanged(); } }); popup.show(e.getComponent(), e.getX(), e.getY()); } } }); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(deelnemersTabel); innerPanel.add(scrollPane, BorderLayout.CENTER); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(deelnemersModel); deelnemersTabel.setRowSorter(sorter); innerPanel.add(new JLabel("Filter op : ")); JTextField tfFilter = new JTextField(10); tfFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String text = tfFilter.getText(); logger.log(Level.INFO, "Filter tabel op : " + text); if (text.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } }); innerPanel.add(tfFilter); JButton btPasToe = new JButton("Apply"); btPasToe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String text = tfFilter.getText(); logger.log(Level.INFO, "Filter tabel op : " + text); if (text.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } }); innerPanel.add(btPasToe); JButton btWis = new JButton("Wis"); btWis.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { tfFilter.setText(""); logger.log(Level.INFO, "Wis filter"); sorter.setRowFilter(null); } }); innerPanel.add(btWis); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(0), 30); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(1), 55); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(2), 170); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(3), 40); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(4), 40); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(5), 30); Utils.fixedComponentSize(scrollPane, 400, 580); return panel; }
From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java
/** * Shows information in a tooltip about the sequence over which the mouse * moved.// w w w . ja v a 2 s .co m * * @param e * MouseEvent */ public void mouseMoved(MouseEvent e) { Point p = e.getPoint(); String str = "<html>"; int height = (int) ((double) (getHeight() - (2 * border))); int unitHeight = height / getHashMapSize(); int currentTop = 0; String key = null; AbstractLogUnit item = null; boolean flag = false; // for dot int index = -1; for (Iterator itSets = dcModel.getSortedKeySetList().iterator(); itSets.hasNext();) { key = (String) itSets.next(); if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key)) continue; index++; LogUnitList tempLogUnit = (LogUnitList) dcModel.getItemMap().get(key); currentTop = unit2Cord(index) + unitHeight / 2; if (currentTop - 5 >= p.getY() || p.getY() >= currentTop + 5) continue; // get the descriptiveStatistics object for (Iterator itItm = tempLogUnit.iterator(); itItm.hasNext();) { item = (AbstractLogUnit) itItm.next(); if (dcModel.getEventTypeToKeep() != null && (!dcModel.getEventTypeToKeep().contains(item.getType()) || !dcModel.getInstanceTypeToKeep().contains(item.getProcessInstance().getName()))) continue; int x = 0; x = time2coord(item.getCurrentTimeStamp()) + border; if (x - 5 <= p.getX() && p.getX() <= x + 5) { flag = true; str += item.getProcessInstance().getName() + " | " + item.getElement() + " | " + item.getOriginator() + " | " + item.getTimestamp() + " | " + item.getType(); if (!timeOption.equals(TIME_ACTUAL)) str += " | Position:" + timeFormat(item.getCurrentTimeStamp()); str += "<br>"; } } } // for item line index = -1; for (Iterator itSets = dcModel.getSortedKeySetList().iterator(); itSets.hasNext();) { key = (String) itSets.next(); if (dcModel.getTypeHashMap().equals(ST_INST) && !dcModel.getInstanceTypeToKeep().contains(key)) continue; index++; LogUnitList tempLogUnit = (LogUnitList) dcModel.getItemMap().get(key); currentTop = unit2Cord(index) + unitHeight / 2; if (currentTop - 5 >= p.getY() || p.getY() >= currentTop + 5) continue; LogUnitList tempUnitList = new LogUnitList(); // get the descriptiveStatistics object for (Iterator itItm = tempLogUnit.iterator(); itItm.hasNext();) { item = (AbstractLogUnit) itItm.next(); if (dcModel.getEventTypeToKeep() != null && (!dcModel.getEventTypeToKeep().contains(item.getType()) || !dcModel.getInstanceTypeToKeep().contains(item.getProcessInstance().getName()))) continue; if (bDrawLine && item.getType().equals(dca.getSettingPanel().getStartEvent())) { tempUnitList.addEvent(item); continue; } if (bDrawLine && item.getType().equals(dca.getSettingPanel().getEndEvent())) { for (Iterator itr = tempUnitList.iterator(); itr.hasNext();) { AbstractLogUnit item2 = (AbstractLogUnit) itr.next(); if (item2.getElement().equals(item.getElement()) && item2.getProcessInstance().equals(item.getProcessInstance())) { int x1 = time2coord(item2.getCurrentTimeStamp()) + border; int x2 = time2coord(item.getCurrentTimeStamp()) + border; if (x1 + 5 <= p.getX() && p.getX() <= x2 - 5) { flag = true; str += item.getProcessInstance().getName() + " | " + item.getElement() + " | " + item.getOriginator() + " |(start)" + item.getTimestamp() + "-(complete)" + item2.getTimestamp() + "<br>"; tempUnitList.removeEvent(item2); } break; } } } } } str += "</html>"; if (flag) { this.setToolTipText(str); repaint(); bTooltip = true; } else { this.setToolTipText(null); if (bTooltip) { repaint(); bTooltip = false; } } }
From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java
public void mousePressed(MouseEvent e) { if (!clicked && dcOptionPanel.getMouseMode().equals(ST_ZOOMIN)) { clicked = true;// w w w. j a v a 2 s.c o m p1 = e.getPoint(); p2 = e.getPoint(); repaint(); } else { p3 = e.getPoint(); p4 = dca.getScrollPane().getViewport().getViewPosition(); } }
From source file:edu.ku.brc.ui.tmanfe.SpreadSheet.java
@Override public void processMouseEvent(MouseEvent ev) { int type = ev.getID(); //int modifiers = ev.getModifiers(); mouseDown = type == MouseEvent.MOUSE_PRESSED; // XXX For Java 5 Bug // I am not sure if we still need this if (mouseDown && UIHelper.getOSType() == UIHelper.OSTYPE.MacOSX) { int rowIndexStart = rowAtPoint(ev.getPoint()); int colIndexStart = columnAtPoint(ev.getPoint()); //System.out.println(isEditing()+" "+rowIndexStart+" "+colIndexStart+" "+prevRowSelInx+" "+prevColSelInx+" "); if (isEditing() && (prevRowSelInx != rowIndexStart || prevColSelInx != colIndexStart)) { getCellEditor().stopCellEditing(); }/* w w w. j a va 2s. c om*/ } // Done - For Java 5 Bug if (ev.isPopupTrigger()) { // No matter what, stop editing if we are editing if (isEditing()) { getCellEditor().stopCellEditing(); } // Now check to see if we right clicked on a different rowor column boolean isOnSelectedCell = false; int rowIndexStart = rowAtPoint(ev.getPoint()); int colIndexStart = columnAtPoint(ev.getPoint()); // Check to see if we are in the selection of mulitple rows and cols if (getSelectedRowCount() > 0) { int[] cols = getSelectedColumns(); for (int r : getSelectedRows()) { if (r == rowIndexStart) { for (int c : cols) { if (c == colIndexStart) { isOnSelectedCell = true; break; } } } } } if (!isOnSelectedCell) { setRowSelectionInterval(rowIndexStart, rowIndexStart); setColumnSelectionInterval(colIndexStart, colIndexStart); } if (popupMenu != null) { popupMenu.setVisible(false); } popupMenu = createMenuForSelection(ev.getPoint()); if (popupMenu.isVisible()) { popupMenu.setVisible(false); } else { //popupMenu.setTargetCells(_selection); Point p = getLocationOnScreen(); popupMenu.setLocation(p.x + ev.getX() + 1, p.y + ev.getY() + 1); popupMenu.setVisible(true); } } super.processMouseEvent(ev); }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
@Override public void mouseMoved(final MouseEvent e) { final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint()); updateActivehexCoord(hexNumber);//from w w w. j a va2 s . c o m ToolTipManager.sharedInstance().mouseMoved(e); }