List of usage examples for java.awt.event MouseEvent getClickCount
public int getClickCount()
From source file:Main.java
public static MouseEvent convertMouseEvent(Component source, MouseEvent sourceEvent, Component destination) { Point p = SwingUtilities.convertPoint(source, new Point(sourceEvent.getX(), sourceEvent.getY()), destination);//from www.j a va 2s . c om Component newSource; if (destination != null) newSource = destination; else newSource = source; MouseEvent newEvent; if (sourceEvent instanceof MouseWheelEvent) { MouseWheelEvent sourceWheelEvent = (MouseWheelEvent) sourceEvent; newEvent = new MouseWheelEvent(newSource, sourceWheelEvent.getID(), sourceWheelEvent.getWhen(), sourceEvent.getModifiers() | sourceEvent.getModifiersEx(), p.x, p.y, sourceWheelEvent.getClickCount(), sourceWheelEvent.isPopupTrigger(), sourceWheelEvent.getScrollType(), sourceWheelEvent.getScrollAmount(), sourceWheelEvent.getWheelRotation()); } else if (sourceEvent instanceof MenuDragMouseEvent) { MenuDragMouseEvent sourceMenuDragEvent = (MenuDragMouseEvent) sourceEvent; newEvent = new MenuDragMouseEvent(newSource, sourceMenuDragEvent.getID(), sourceMenuDragEvent.getWhen(), sourceEvent.getModifiers() | sourceEvent.getModifiersEx(), p.x, p.y, sourceMenuDragEvent.getClickCount(), sourceMenuDragEvent.isPopupTrigger(), sourceMenuDragEvent.getPath(), sourceMenuDragEvent.getMenuSelectionManager()); } else { newEvent = new MouseEvent(newSource, sourceEvent.getID(), sourceEvent.getWhen(), sourceEvent.getModifiers() | sourceEvent.getModifiersEx(), p.x, p.y, sourceEvent.getClickCount(), sourceEvent.isPopupTrigger(), sourceEvent.getButton()); } return newEvent; }
From source file:com.openbravo.pos.customers.JCustomerFinder.java
private void jListCustomersMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListCustomersMouseClicked if (evt.getClickCount() == 2) { selectedCustomer = (CustomerInfo) jListCustomers.getSelectedValue(); dispose();//from w ww .jav a 2 s . co m } }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.css.FerramentaCSSPanel.java
/** * Captura o evento de mouse na tabela de erros *//*w w w . j a v a 2 s . c om*/ public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { int row = this.tabelaDeErros.getSelectedRow(); int col = this.tabelaDeErros.getSelectedColumn(); if (row == -1) { return; } if (col == 2) { /* * Abrir um help */ String texto = tabelaDeErros.getValueAt(row, 1).toString(); openHelp(texto); } else { int linhaToGo = Integer.parseInt(tabelaDeErros.getValueAt(row, 0).toString()); textAreaSourceCode.goToLine(linhaToGo); textAreaSourceCode.selectLine(linhaToGo); } } }
From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java
/** * Inits the./*from w ww .j av a 2 s . c o m*/ */ private void init() { // build menu buildMenu(); // add double click listener MouseListener mouseListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() == 2 && !e.isConsumed() && e.getButton() == MouseEvent.BUTTON1) { actionEdit2.actionPerformed(new ActionEvent(e, 0, "")); } } }; tree.addMouseListener(mouseListener); }
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.table.JPanCMTableArea.java
private void mouseClickedAction(JTableMatchedInfo jTableMatchedInfo, MouseEvent e) { jPanCodeMatchMain.resetNavigator();//from www . j ava 2s .c o m jPanCodeMatchMain.resetSelectSnippetNum(); JRadioButton rdbtnOpt1IConform = jPanCodeMatchMain.getJRadioButtonOpt1(); int prevSelectedCodeMatchTableIndex = jPanCodeMatchMain.getPrevSelectedCodeMatchTableIndex(); int selectedRow = jTableMatchedInfo.getSelectedRow(); IdentifyMediator.getInstance().updateUIOKResetButtonForSMCM(jTableMatchedInfo, selectedRow); if (e.getClickCount() != IdentificationConstantValue.MOUSE_DOUBLE_CLICK) { if (rdbtnOpt1IConform.isSelected()) { String selectedLicenseName = (String) jTableMatchedInfo.getValueAt(selectedRow, 2); selectedLicenseName = DCCodeMatch.getOriginValue(selectedLicenseName); IdentifyMediator.getInstance().setSelectedLicenseName(selectedLicenseName); log.debug("selectedLicenseName by mouse selection : " + selectedLicenseName); } int lSelectedCodeMatchTableIndex = jTableMatchedInfo.getSelectedRow(); if (prevSelectedCodeMatchTableIndex != lSelectedCodeMatchTableIndex) { if (jTableMatchedInfo.getSelectedRow() >= 0 && jTableMatchedInfo.getModel().getColumnCount() > 5) { jPanCodeMatchMain.updateSourceCodeView(); } prevSelectedCodeMatchTableIndex = lSelectedCodeMatchTableIndex; } return; } }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.navegacao_cego.PainelSimuladorNavegacao.java
public void mouseClicked(MouseEvent e) { try {/*from www. ja v a 2 s .c om*/ if (e.getClickCount() == 2) { TabelaDescricao tcl = ((TabelaDescricao) e.getComponent()); int caretPosition = 0; int linhaSelecionada = tcl.getSelectedRow(); int colSelecionada = tcl.getSelectedColumn(); // System.out.println("resultados="+controle.getArrResultado().size()); this.textAreaSourceCode.getTextPane().setCaretPosition(0); if (colSelecionada == 0) { caretPosition = controle.getArrResultado().get(linhaSelecionada).getOrigem().getIndexOf(); } else { caretPosition = controle.getArrResultado().get(linhaSelecionada).getDestino().getIndexOf(); } // System.out.println("caretPosition="+caretPosition); String txt = this.textAreaSourceCode.getTextPane().getText().substring(caretPosition); if (txt.length() > 5) { txt = txt.substring(0, 5); } // System.out.println("\ttxt="+txt); this.textAreaSourceCode.getTextPane().setCaretPosition(caretPosition); this.textAreaSourceCode.getTextPane().select(caretPosition, txt.length() + caretPosition); this.textAreaSourceCode.getTextPane().requestFocus(); } } catch (Exception e1) { } }
From source file:gdsc.smlm.ij.plugins.ResultsManager.java
public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) // Double-click {//from w w w .ja v a 2 s . co m TextField text = (e.getSource() == text1) ? text1 : text2; String[] path = Utils.decodePath(text.getText()); OpenDialog chooser = new OpenDialog("Coordinate file", path[0], path[1]); if (chooser.getFileName() != null) { text.setText(chooser.getDirectory() + chooser.getFileName()); } } }
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 ww w . j a va 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:au.org.ala.delta.editor.ui.CharacterTree.java
public CharacterTree() { setToggleClickCount(0);// ww w .ja va 2 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:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.QueryComponentExpressionPanel.java
/** * Creates the excluded terms panel./*w ww. j a v a 2s .co m*/ */ private synchronized void createExcludedTermsPanel() { // create table for displaying excluded constraints excludedConstraintTableModel = new TerminologyConstraintTableModel(); excludedConstraintsTable = new JTable(excludedConstraintTableModel); excludedConstraintsTable.setDefaultRenderer(TerminologyConstraint.class, new TerminologyConstraintTableCellRenderer(humanReadableRender)); excludedConstraintsTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // get row a click int row = excludedConstraintsTable.rowAtPoint(e.getPoint()); if (row > -1 && e.getClickCount() == 2) { // addingNew = false; editingExisting = true; // get constraint at row activeTerminologyConstraint = excludedConstraintTableModel.getConstraintAtRow(row); // set constraint in activeConstraintPanel and display activeConstraintsDialog activeConstraintPanel.setConstraint(activeTerminologyConstraint); activeConstraintsDialog.setVisible(true); } } }); // create a label and control buttons for editing excluded constraints JPanel p3 = new JPanel(); p3.setLayout(new BoxLayout(p3, BoxLayout.LINE_AXIS)); p3.add(new JLabel("Edit excluded constraints")); p3.add(Box.createHorizontalGlue()); // add panel for editing excluded terms JideButton addExclusionTermButton = new JideButton(new AbstractAction("", addExclusionIcon) { public void actionPerformed(ActionEvent e) { // show activeConstraintsDialog // addingNew = true; activeConstraintsDialog.setVisible(true); } }); addExclusionTermButton.setName("addExclusionTermButton"); JideButton deleteExclusionTermButton = new JideButton(new AbstractAction("", deleteExclusionIcon) { public void actionPerformed(ActionEvent e) { final int row = excludedConstraintsTable.getSelectedRow(); if (row > -1) { QueryStatement oldValue = queryService.getActiveQuery(); // get term at row TerminologyConstraint term = (TerminologyConstraint) excludedConstraintTableModel .getValueAt(row, 1); // remove term from sub query componentExpression.removeExcludedConstraint(term); Runnable runnable = new Runnable() { public void run() { excludedConstraintTableModel.deleteRow(row); } }; SwingUtilities.invokeLater(runnable); // notify listeners propertyChangeTrackerService.firePropertyChanged(ACTIVE_QUERY_CHANGED, oldValue, queryService.getActiveQuery(), QueryComponentExpressionPanel.this); } } }); deleteExclusionTermButton.setName("deleteExclusionTermButton"); // add buttons to p3 p3.add(addExclusionTermButton); p3.add(deleteExclusionTermButton); // create panel that contains excluded constraints excludedConstraintsPanel = new JPanel(new BorderLayout()); excludedConstraintsPanel.setBorder(BorderFactory.createTitledBorder("Excluded constraints")); excludedConstraintsPanel.add(p3, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(excludedConstraintsTable); excludedConstraintsPanel.add(scrollPane, BorderLayout.CENTER); }