Java Code Examples for java.awt.event.MouseEvent#getClickCount()

The following examples show how to use java.awt.event.MouseEvent#getClickCount() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ghidra   File: DomainFilesPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
	if (e.getClickCount() != 1) {
		return;
	}

	JList list = (JList) e.getSource();
	int index = list.locationToIndex(e.getPoint());
	if (index < 0) {
		return;
	}
	boolean selected = checkboxes[index].isSelected();
	checkboxes[index].setSelected(!selected);
	// The following repaint() is to get the check box state to get refreshed on the screen.
	// Prior to adding this the check box did not refresh the display of its state in the
	// list when selected multiple times in a row. It only seemed to repaint when focus 
	// was lost.
	list.repaint();
}
 
Example 2
Source Project: chipster   File: TreePanel.java    License: MIT License 6 votes vote down vote up
@Override
  public void mousePressed(MouseEvent e) {

maybeShowPopup(e);
  	// double click
  	if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) {
  		
  		DataItem selectedItem = this.getSelectedElementFrom(e);
  		
  		if (selectedItem instanceof DataBean) {        			
  			application.visualiseWithBestMethod(FrameType.MAIN);
  			
  		} else if (selectedItem instanceof DataFolder) {
  			// select all child beans
  			DataFolder folder = (DataFolder)selectedItem;
  			application.getSelectionManager().clearAll(false, this);
  			application.getSelectionManager().selectMultiple(folder.getChildren(), this);
  		}
  	} 
  }
 
Example 3
public void addMouseListenerToHeaderInTable(JTable table) {
    final TableSorter sorter = this;
    final JTable tableView = table;
    tableView.setColumnSelectionAllowed(false);
    final MouseAdapter listMouseListener = new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            final TableColumnModel columnModel = tableView.getColumnModel();
            final int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            final int column = tableView.convertColumnIndexToModel(viewColumn);
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ...");
                final int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK;
                final boolean ascending = (shiftPressed == 0);
                sorter.sortByColumn(column, ascending);
            }
        }
    };
    final JTableHeader th = tableView.getTableHeader();
    th.addMouseListener(listMouseListener);
}
 
Example 4
@Override
public void mouseClicked(final MouseEvent e) {
    if (e.getClickCount() > 1) {
        if (e.getButton() == MouseEvent.BUTTON1) {
            removeSelectedFromDeck();
        } else if (e.getButton() == MouseEvent.BUTTON3) {
            final List<MagicCardDefinition> deckCards = deckTable.getSelectedCards();
            if (deckCards.size() > 0) {
                deck.addAll(deckCards);
                updateDeck();
            }
        }
    }
    if (e.getButton() == MouseEvent.BUTTON3) {
        final JTable table = (JTable) (e.getSource());
        final int row = table.rowAtPoint(e.getPoint());
        table.clearSelection();
        table.addRowSelectionInterval(row, row);
    }
}
 
Example 5
public void mouseClicked(MouseEvent e) {
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = tableView.convertColumnIndexToModel(viewColumn);
    if (e.getClickCount() == 1 && column != -1) {
        if (tableView instanceof XTable) {
            XTable attrs = (XTable) tableView;
            // inform the table view that the rows are going to be sorted
            // against the values in a given column. This gives the
            // chance to the table view to close its editor - if needed.
            //
            attrs.sortRequested(column);
        }
        tableView.invalidate();
        sortByColumn(column);
        tableView.validate();
        tableView.repaint();
    }
}
 
Example 6
Source Project: PIPE   File: AnnotationAction.java    License: MIT License 5 votes vote down vote up
/**
 * Called when this action is selected and the user has pressed on the canvas
 * Adds a new annotation and registers an undo event for its addition.
 * @param event              mouse event
 * @param petriNetController controller for the petri net
 */
@Override
public void doAction(MouseEvent event, PetriNetController petriNetController) {
    if (event.getClickCount() > 0) {
        Point point = event.getPoint();
        Annotation annotation = getAnnotation(point, petriNetController);
        PetriNet net = petriNetController.getPetriNet();
        registerUndoEvent(new AddPetriNetObject(annotation, net));
    }
}
 
Example 7
Source Project: PIPE   File: ArcAction.java    License: MIT License 5 votes vote down vote up
/**
 * Changes the temporary arc's end point
 *
 * @param event              mouse event that has just been fired
 * @param petriNetController current petri net controller for the tab showing
 */
@Override
public void doAction(MouseEvent event, PetriNetController petriNetController) {
    if (temporaryArcView != null) {
        temporaryArcView.setEnd(event.getPoint());
        if (event.getClickCount() > 0) {
            Point point = event.getPoint();
            temporaryArcView.addIntermediatePoint(new ArcPoint(point, event.isShiftDown()));
        }

        PetriNetTab tab = petriNetController.getPetriNetTab();
        tab.validate();
        tab.repaint();
    }
}
 
Example 8
@Override
public void mouseClicked(MouseEvent e) {
	super.mouseClicked(e);
	if (!isAttached()) {
		return;
	}

	if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
		pm.actionOpen.actionPerformed(UiUtils.actionEvent(table, pm.actionOpen));
		return;
	}
}
 
Example 9
private void selectionProcedure(DBBrowserNode selectedNode, MouseEvent e) {

		ViewProcedureColumnsInfoAction infoAction = new ViewProcedureColumnsInfoAction(selectedNode.getDBObject());
		if (e.getClickCount() == 2) {
			infoAction.actionPerformed(null);
		} else {
			JPopupMenu popupMenu = new JPopupMenu();
			JMenuItem menuItem = new JMenuItem(infoAction);
			popupMenu.add(menuItem);
			JMenuItem menuItem2 = new JMenuItem(new ValidateProceduresAction(selectedNode.getDBObject()));
			popupMenu.add(menuItem2);
			popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
		}
	}
 
Example 10
Source Project: jdk8u60   File: MBeansTab.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
    if (e.getClickCount() == 1) {
        int selRow = tree.getRowForLocation(e.getX(), e.getY());
        if (selRow != -1) {
            TreePath selPath =
                    tree.getPathForLocation(e.getX(), e.getY());
            DefaultMutableTreeNode node =
                    (DefaultMutableTreeNode) selPath.getLastPathComponent();
            if (sheet.isMBeanNode(node)) {
                tree.expandPath(selPath);
            }
        }
    }
}
 
Example 11
Source Project: java-swing-tips   File: MainPanel.java    License: MIT License 5 votes vote down vote up
@Override public void mouseClicked(MouseEvent e) {
  boolean isDoubleClick = e.getClickCount() >= 2;
  if (isDoubleClick) {
    Component src = e.getComponent();
    Dimension dim = src.getSize();
    rect.setBounds(getTitleBounds(src, 0, 0, dim.width, dim.height));
    if (rect.contains(e.getPoint())) {
      startEditing.actionPerformed(new ActionEvent(src, ActionEvent.ACTION_PERFORMED, ""));
    }
  }
}
 
Example 12
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() > 1) {
        startBlinking();
        requestFocus();
    }
}
 
Example 13
@Override
public void mousePressed(MouseEvent e) {
    if (e.getClickCount() == 1) {
        int selRow = tree.getRowForLocation(e.getX(), e.getY());
        if (selRow != -1) {
            TreePath selPath =
                    tree.getPathForLocation(e.getX(), e.getY());
            DefaultMutableTreeNode node =
                    (DefaultMutableTreeNode) selPath.getLastPathComponent();
            if (sheet.isMBeanNode(node)) {
                tree.expandPath(selPath);
            }
        }
    }
}
 
Example 14
public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() > 1) {
        // Double click
        int index = getCircleIndexFromPosition(e.getPoint().x);
        model.setPositions(index, index);
    }
}
 
Example 15
/** 
 * Do mouse clicked.
 * @param e the event 
 */
protected void doMouseClicked(MouseEvent e) {
	if (e.getClickCount() == 2) {
		int idx = videoTable.getSelectedRow();
		idx = videoTable.convertRowIndexToModel(idx);
		currentVideo = videoModel.rows.get(idx);
		position.setValue(0);
		doPlay();
	}
}
 
Example 16
@Override
public boolean fieldElementClicked(Object clickedObject, Navigatable sourceNavigatable,
		ProgramLocation location, MouseEvent mouseEvent, ServiceProvider serviceProvider) {
	if (mouseEvent.getClickCount() != 2 || mouseEvent.getButton() != MouseEvent.BUTTON1) {
		return false;
	}
	return ((AnnotatedTextFieldElement) clickedObject).handleMouseClicked(sourceNavigatable,
		serviceProvider);
}
 
Example 17
Source Project: ghidra   File: ErrorFieldMouseHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean fieldElementClicked(Object clickedObject, Navigatable sourceNavigatable,
		ProgramLocation location, MouseEvent mouseEvent, ServiceProvider serviceProvider) {

	if (mouseEvent.getClickCount() != 2 || mouseEvent.getButton() != MouseEvent.BUTTON1) {
		return false;
	}
	ErrorListingField errorField = (ErrorListingField) clickedObject;
	String fieldName = errorField.getFieldFactory().getFieldName();
	Msg.showError(this, null, "Listing Field Exception", "Exception occurred while rendering '" +
		fieldName + "' field", errorField.getThrowable());
	return true;
}
 
Example 18
Source Project: binnavi   File: CAddressSelectionDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void mousePressed(final MouseEvent event) {
  // Update the selected element on double-click
  if ((event.getButton() == 1) && (event.getClickCount() == 2)) {
    setSelectedElement();
  }

  // Close the dialog on double-click
  if (m_selectionResult != null) {
    closeDialog();
  }
}
 
Example 19
/**
 * Action on mouse click within the table.
 * @param e the mouse event
 */
protected void doMouseClicked(MouseEvent e) {
	if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1) {
		doPlaySelected();
	}
}
 
Example 20
/**
 * 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.
 *
 * @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;
}