List of usage examples for java.awt.event MouseEvent getClickCount
public int getClickCount()
From source file:com.igormaznitsa.sciareto.ui.tree.ExplorerTree.java
public ExplorerTree(@Nonnull final Context context) { super();//www .j av a2 s.c om 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:playground.sergioo.networkBusLaneAdder2012.gui.BusLaneAdderPanel.java
@Override public void mouseClicked(MouseEvent e) { double[] p = getWorld(e.getX(), e.getY()); if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON3) camera.centerCamera(p);// w w w . j a v a 2 s .c om else { if (busLaneAdderWindow.getOption().equals(Options.SELECT_NODES) && e.getButton() == MouseEvent.BUTTON1) { ((NetworkTwoNodesPainterManager) ((NetworkPainter) getActiveLayer().getPainter()) .getNetworkPainterManager()).selectNearestNode(p[0], p[1]); busLaneAdderWindow.refreshLabel(Labels.NODES); } else if (busLaneAdderWindow.getOption().equals(Options.SELECT_NODES) && e.getButton() == MouseEvent.BUTTON3) { ((NetworkTwoNodesPainterManager) ((NetworkPainter) getActiveLayer().getPainter()) .getNetworkPainterManager()).unselectNearestNode(p[0], p[1]); busLaneAdderWindow.refreshLabel(Labels.NODES); } else if (busLaneAdderWindow.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON1) { camera.zoomIn(p[0], p[1]); } else if (busLaneAdderWindow.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON3) { camera.zoomOut(p[0], p[1]); } } repaint(); }
From source file:corina.cross.AllScoresView.java
private void makeDoubleClickable() { // double-click-able table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) // double-clicks only graphSelectedCrossdate(); }//w w w . j a v a 2 s . c o m }); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java
@Override public void mouseClicked(final MouseEvent event) { if (event.getButton() != MouseEvent.BUTTON1) return;// w ww .ja v a2 s . c om if (event.getClickCount() < 2) return; event.consume(); if (m_edit && event.isShiftDown()) { // TODO: insert points into current line } if (m_lineBuilder != null) { try { final GM_Curve curve = (GM_Curve) m_lineBuilder.finish(); finishLine(curve); } catch (final Exception e) { e.printStackTrace(); reinit(); } } }
From source file:simplealbum.mvc.autocomplete.DController.java
@Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 1) { // System.out.println("Solo fue 1"); // dController.processPreSelection(); } else {// w ww .ja v a 2 s . co m //TODO Se puede asociar la action ??? al doble click processSelection(); action = "NEXT"; view.setVisible(false); } //System.out.println("en mousadasd ads en dcontroller"); }
From source file:ja.lingo.application.gui.main.describer.DescriberGui.java
public void mouseClickedOnEditorPane(MouseEvent e) { if (!articlePanel.hasArticle()) { return;/* w w w .jav a 2 s.c o m*/ } if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) { if (getSelectedTextTrimmed().length() > 0) { Rectangle rectangle; try { rectangle = articlePanel.getEditorPane() .modelToView(articlePanel.getEditorPane().getSelectionStart()); } catch (BadLocationException e1) { throw new RuntimeException(e1); } showMenuOnSelect(e.getX(), (int) (rectangle.getY() + rectangle.getHeight())); } return; } if (SwingUtilities.isRightMouseButton(e)) { if (getSelectedTextTrimmed().length() > 0) { showMenuOnSelect(e.getX(), e.getY()); } else { menu.show(articlePanel, e.getX(), e.getY()); } } }
From source file:nz.govt.natlib.ndha.manualdeposit.CMSSearchResultsPresenter.java
private void tableMouseClicked(final java.awt.event.MouseEvent evt) { selectData();//from w ww .j a va 2s . co m if (evt.getClickCount() > 1) { selectRecord(); } }
From source file:org.pentaho.reporting.libraries.designtime.swing.date.DateCellEditor.java
/** * Asks the editor if it can start editing using <code>anEvent</code>. <code>anEvent</code> is in the invoking * component coordinate system. The editor can not assume the Component returned by * <code>getCellEditorComponent</code> is installed. This method is intended for the use of client to avoid the cost * of setting up and installing the editor component if editing is not possible. If editing can be started this method * returns true.//from w w w . ja v a 2 s .c om * * @param anEvent the event the editor should use to consider whether to begin editing or not * @return true if editing can be started * @see #shouldSelectCell */ public boolean isCellEditable(final EventObject anEvent) { if (anEvent instanceof MouseEvent) { final MouseEvent mouseEvent = (MouseEvent) anEvent; return mouseEvent.getClickCount() >= 2 && mouseEvent.getButton() == MouseEvent.BUTTON1; } return true; }
From source file:playground.sergioo.capacitiesChanger2012.gui.NetworkPanel.java
@Override public void mouseClicked(MouseEvent e) { double[] p = getWorld(e.getX(), e.getY()); if (e.getClickCount() == 2) { if (window.getOption().equals(Options.SELECT_LINK) && e.getButton() == MouseEvent.BUTTON1) { ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectLink(p[0], p[1]); Link link = ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager() .getSelectedLink();// w ww . ja v a 2s .co m try { link.setCapacity( Double.parseDouble(JOptionPane.showInputDialog("New capacity", link.getCapacity()))); } catch (Exception e2) { } ((SimpleSelectionNetworkPainter) getActiveLayer().getPainter()).calculateMinMax(); window.refreshLabel(Labels.LINK); } else if (e.getButton() == MouseEvent.BUTTON3) { ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectLink(p[0], p[1]); Link link = ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager() .getSelectedLink(); try { link.setFreespeed( Double.parseDouble(JOptionPane.showInputDialog("New free speed", link.getFreespeed()))); } catch (Exception e2) { } ((SimpleSelectionNetworkPainter) getActiveLayer().getPainter()).calculateMinMax(); window.refreshLabel(Labels.LINK); } } else { if (window.getOption().equals(Options.SELECT_LINK) && e.getButton() == MouseEvent.BUTTON1) { ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectLink(p[0], p[1]); window.refreshLabel(Labels.LINK); } else if (window.getOption().equals(Options.SELECT_LINK) && e.getButton() == MouseEvent.BUTTON3) { ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().unselectLink(); window.refreshLabel(Labels.LINK); } else if (window.getOption().equals(Options.SELECT_NODE) && e.getButton() == MouseEvent.BUTTON1) { ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectNode(p[0], p[1]); window.refreshLabel(Labels.NODE); } else if (window.getOption().equals(Options.SELECT_NODE) && e.getButton() == MouseEvent.BUTTON3) { ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().unselectNode(); window.refreshLabel(Labels.NODE); } else if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON1) camera.zoomIn(p[0], p[1]); else if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON3) camera.zoomOut(p[0], p[1]); } repaint(); }
From source file:ja.lingo.application.gui.main.settings.dictionaries.add.AddPanel.java
public void onReaderListClicked(MouseEvent e) { if (!SwingUtilities.isLeftMouseButton(e)) { return;//from w w w .ja v a2 s. com } if (e.getClickCount() != 2) { return; } fileChooser.askForFile(parentDialog); }