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

The following are Jave code examples for showing how to use getClickCount() of the java.awt.event.MouseEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: RevertDeletedAction.java   View Source Code Vote up 8 votes
@Override
public void mouseClicked(MouseEvent e) {
    JTree tree = (JTree) e.getSource();
    Point p = e.getPoint();
    int row = tree.getRowForLocation(e.getX(), e.getY());
    TreePath path = tree.getPathForRow(row);
    
    // if path exists and mouse is clicked exactly once
    if (path != null) {
        FileNode node = (FileNode) path.getLastPathComponent();
        Rectangle chRect = DeletedListRenderer.getCheckBoxRectangle();
        Rectangle rowRect = tree.getPathBounds(path);
        chRect.setLocation(chRect.x + rowRect.x, chRect.y + rowRect.y);
        if (e.getClickCount() == 1 && chRect.contains(p)) {
            boolean isSelected = !(node.isSelected());
            node.setSelected(isSelected);
            ((DefaultTreeModel) tree.getModel()).nodeChanged(node);
            if (row == 0) {
                tree.revalidate();
            }
            tree.repaint();
        }
    }
}
 
Example 2
Project: Reinickendorf_SER316   File: TableSorter.java   View Source Code Vote up 6 votes
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ..."); 
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
Example 3
Project: rapidminer   File: PlotterMouseHandler.java   View Source Code Vote up 6 votes
@Override
public void mouseClicked(MouseEvent e) {
	if (e.getButton() == MouseEvent.BUTTON1) {
		if (e.getClickCount() > 1) {
			String id = plotter.getIdForPos(e.getX(), e.getY());
			if (id != null) {
				ObjectVisualizer visualizer = ObjectVisualizerService.getVisualizerForObject(dataTable);
				visualizer.startVisualization(id);
			}
		}
	} else if (e.getButton() == MouseEvent.BUTTON3) {
		plotter.setDrawRange(-1, -1, -1, -1);
		pressStart = null;
		plotter.setDragBounds(-1, -1, -1, -1);
	}
}
 
Example 4
Project: marathonv5   File: RTree.java   View Source Code Vote up 6 votes
@Override protected void mousePressed(MouseEvent me) {
    // Ignore double clicks on non-leaf tree nodes
    if (me.getButton() == MouseEvent.BUTTON1 && me.getModifiersEx() == InputEvent.BUTTON1_DOWN_MASK) {
        if (me.getClickCount() == 1) {
            return;
        }
        TreePath path = ((JTree) component).getPathForRow(row);
        if (path != null) {
            Object lastPathComponent = path.getLastPathComponent();
            if (lastPathComponent instanceof TreeNode) {
                TreeNode node = (TreeNode) lastPathComponent;
                if (node.getChildCount() != 0) {
                    return;
                }
            }
        }
    }
    // Ignore Ctrl+Clicks used to select the nodes
    if (me.getButton() == MouseEvent.BUTTON1 && isMenuShortcutKeyDown(me)) {
        return;
    }
    if (me.getButton() != MouseEvent.BUTTON1) {
        focusLost(null);
    }
    super.mousePressed(me);
}
 
Example 5
Project: scorekeeperfrontend   File: ClassTree.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e)
{
	if (e.getClickCount() == 2)
	{
		processSelection();
	}
}
 
Example 6
Project: marathonv5   File: RComponent.java   View Source Code Vote up 5 votes
protected void mousePressed(MouseEvent me) {
    if (me.getButton() == MouseEvent.BUTTON1 && me.getClickCount() == 1 && !me.isAltDown() && !me.isMetaDown()
            && !me.isAltGraphDown() && !me.isControlDown()) {
        mouseButton1Pressed(me);
    } else {
        recorder.recordClick2(this, me, true);
    }
}
 
Example 7
Project: gate-core   File: LuceneDataStoreSearchGUI.java   View Source Code Vote up 5 votes
@Override
public void mousePressed(MouseEvent e) {
  if(e.isPopupTrigger() && type != null && feature != null) {
    createPopup(e);
    mousePopup.show(e.getComponent(), e.getX(), e.getY());
  } else if(e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
    updateQuery();
  }
}
 
Example 8
Project: OrthancAnonymization   File: TablePatientsMouseListener.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent event) {
	if (event.isControlDown() && SwingUtilities.isLeftMouseButton(event) && event.getClickCount() == 1) {
           int row = tableau.rowAtPoint(event.getPoint());
           listSelection.addSelectionInterval(row, row);
       }
}
 
Example 9
Project: JavaGraph   File: RuleTree.java   View Source Code Vote up 5 votes
@Override
public void mousePressed(MouseEvent evt) {
    TreePath path = getPathForLocation(evt.getX(), evt.getY());
    if (path != null) {
        if (evt.getButton() == MouseEvent.BUTTON3 && !isRowSelected(getRowForPath(path))) {
            setSelectionPath(path);
        }
        DisplayKind toDisplay = null;
        Object lastComponent = path.getLastPathComponent();
        if (lastComponent instanceof RuleTreeNode) {
            toDisplay = DisplayKind.RULE;
        } else if (lastComponent instanceof RecipeTreeNode) {
            toDisplay = DisplayKind.CONTROL;
        } else if (lastComponent instanceof MatchTreeNode
            && getSimulatorModel().getDisplay() != DisplayKind.LTS) {
            toDisplay = DisplayKind.STATE;
        }
        if (evt.getClickCount() == 1 && toDisplay != null) {
            getSimulatorModel().setDisplay(toDisplay);
        } else if (evt.getClickCount() == 2 && toDisplay != null) {
            if (toDisplay.hasResource()) {
                getActions().getEditAction(toDisplay.getResource())
                    .execute();
            }
        }
    }
    maybeShowPopup(evt);
}
 
Example 10
Project: JavaGraph   File: PropertiesDisplay.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2) {
        getActions().getEditSystemPropertiesAction()
            .execute();
    }
}
 
Example 11
Project: incubator-netbeans   File: FieldsBrowserControllerUI.java   View Source Code Vote up 5 votes
public void mouseClicked(MouseEvent e) {
    if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
        int row = fieldsListTable.rowAtPoint(e.getPoint());
        if (e.getX() >= fieldsListTable.getTree().getRowBounds(row).x -
                        fieldsListTable.getTreeCellOffsetX() && row != -1) {
            HeapWalkerNode node = (HeapWalkerNode) fieldsListTable.getTree().
                    getPathForRow(row).getLastPathComponent();
            if (node instanceof HeapWalkerInstanceNode)
                    performDefaultAction();
        }
    }
}
 
Example 12
Project: YtQueue   File: YtQueueFrame.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
    if (e.isControlDown() || e.isShiftDown() && e.getButton() != MouseEvent.BUTTON3) {
        VideoViewer viewer = VideoViewer.INSTANCE;
        if (viewer.PLAYER.isPlaying()) {
            Dimension dim = viewer.PLAYER.getVideoDimension();
            if (e.getButton() == MouseEvent.BUTTON1) {
                updateVisibility(false);
            } else {
                updateVisibility(true);
            }
            YtQueueFrame frame = YtQueueFrame.INSTANCE;
            int x = frame.getX(), y = frame.getY(), w = frame.getWidth(), h = frame.getHeight();
            double simillar = dim.width / (double) w;
            if (e.isShiftDown()) {
                simillar = 1;
            }
            dim.width = (int) (dim.width / simillar);
            dim.height = (int) (dim.height / simillar) +
                         (e.getButton() != MouseEvent.BUTTON2 ? 0 : SearchPanel.INSTANCE.getHeight() +
                                                                    VideoViewer.INSTANCE.MANAGER.getHeight());
            frame.setBounds(x + w - dim.width, y + h - dim.height, dim.width, dim.height);
        }
    }
    if (e.getClickCount() == 2) {
        if (e.getButton() == MouseEvent.BUTTON1) {
            updateVisibility(!SearchPanel.INSTANCE.isVisible());
        } else if (e.getButton() == MouseEvent.BUTTON2) {
            close();
        }
    }
}
 
Example 13
Project: SER316-Munich   File: TaskPanel.java   View Source Code Vote up 5 votes
public void mouseClicked(MouseEvent e) {
if ((e.getClickCount() == 2) && (taskTable.getSelectedRow() > -1)){
	// ignore "tree" column
	//if(taskTable.getSelectedColumn() == 1) return;
	
	editTaskB_actionPerformed(null);
}
     }
 
Example 14
Project: rapidminer   File: IOObjectCacheEntryPanel.java   View Source Code Vote up 5 votes
@Override
public void mouseClicked(MouseEvent e) {
	if (SwingUtilities.isLeftMouseButton(e)) {
		if (e.getClickCount() == 2) {
			openAction.actionPerformed(new ActionEvent(IOObjectCacheEntryPanel.this, ActionEvent.ACTION_PERFORMED,
					null));
		}
	}
}
 
Example 15
Project: incubator-netbeans   File: BrowseFolders.java   View Source Code Vote up 5 votes
public void mouseClicked(MouseEvent e) {
    int selRow = tree.getRowForLocation(e.getX(), e.getY());

    if ((selRow != -1) && SwingUtilities.isLeftMouseButton(e) && (e.getClickCount() % 2) == 0) {
        FileObject fileObject = bf.getSelectedFileObject();
        if (fileObject != null && !fileObject.isFolder())
            options[0].doClick();
    }
}
 
Example 16
Project: jmt   File: SelectState.java   View Source Code Vote up 4 votes
/**
 * Handles press event, it selects the cell that is under the pointer
 * If there is no cell deselects. There is also the possibility of
 * activating the marquee handler
 *
 * @param e press mouse event
 */
@Override
public void handlePress(MouseEvent e) {
	ml.setHandler(null);
	if (!e.isConsumed() && mediator.isGraphEnabled()) {
		mediator.graphRequestFocus();
		int s = mediator.getTolerance();
		Rectangle2D r = mediator.fromScreen(new Rectangle(e.getX() - s, e.getY() - s, 2 * s, 2 * s));
		Point2D point = mediator.fromScreen(new Point(e.getPoint()));
		if (ml.getFocus() != null && (!mediator.containsCell(ml.getFocus().getCell())
				|| !ml.getFocus().intersects(mediator.getGraph(), r))) {
			ml.setFocus(null);
		}
		// Avoid toggling of selection between inner components and blocking region
		CellView next = mediator.getNextViewAt(ml.getFocus(), point.getX(), point.getY());
		if (next != null && next.getCell() != null) {
			if (ml.getFocus() == null || !(next.getCell() instanceof BlockingRegion)) {
				ml.setCell(next);
			}
		}
		if (ml.getFocus() == null) {
			ml.setFocus(ml.getCell());
		}

		if (!mediator.isForceMarqueeEvent(e)) {
			if (e.getClickCount() == mediator.getEditClickCount() && ml.getFocus() != null
					//&& ml.getFocus().isLeaf()
					//&& ml.getFocus().getParentView() == null
					) {
				// Start Editing Only if cell is editable - BERTOLI MARCO
				if (mediator.isCellEditable(ml.getFocus().getCell())) {
					ml.handleEditTrigger(ml.getFocus().getCell());
					e.consume();
					ml.setCell(null);
				} // Otherwise do nothing - BERTOLI MARCO
				else {
					e.consume();
				}
			} else if (!mediator.isToggleSelectionEvent(e)) {
				if (ml.getHandle() != null) {
					ml.setHandler(ml.getHandle());
					ml.getHandle().mousePressed(e);
				}
				// Immediate Selection
				if (!e.isConsumed() && ml.getCell() != null && !mediator.isCellSelected(ml.getCell())) {
					mediator.selectCellForEvent(ml.getCell().getCell(), e);
					ml.setFocus(ml.getCell());
					if (ml.getHandle() != null) {
						ml.getHandle().mousePressed(e);
						ml.setHandler(ml.getHandle());
					}
					e.consume();
					ml.setCell(null);
				}
			}
		}

		//Marquee Selection
		if (!e.isConsumed() && (!mediator.isToggleSelectionEvent(e) || ml.getFocus() == null)) {
			if (ml.getMarquee() != null) {
				ml.getMarquee().mousePressed(e);
				ml.setHandler(ml.getMarquee());
			}
		}
	}
}
 
Example 17
Project: Reinickendorf_SER316   File: NotesControlPanel.java   View Source Code Vote up 4 votes
public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2)
        setActiveNote();
}
 
Example 18
Project: incubator-netbeans   File: Outline.java   View Source Code Vote up 4 votes
@Override
public String getToolTipText(MouseEvent event) {
    try {
        // Required to really get the tooltip text:
        putClientProperty("ComputingTooltip", Boolean.TRUE);

        toolTip = null;
        String tipText = null;
        Point p = event.getPoint();

        // Locate the renderer under the event location
        int hitColumnIndex = columnAtPoint(p);
        int hitRowIndex = rowAtPoint(p);

        if ((hitColumnIndex != -1) && (hitRowIndex != -1)) {
            //Outline tbl = (Outline) table;
            if (convertColumnIndexToModel(hitColumnIndex) == 0) {   // tree column index
                // For tree column get the tooltip directly from the renderer data provider
                RenderDataProvider rendata = getRenderDataProvider();
                if (rendata != null) {
                    Object value = getValueAt(hitRowIndex, hitColumnIndex);
                    if (value != null) {
                        String toolT = rendata.getTooltipText(value);
                        if (toolT != null && (toolT = toolT.trim ()).length () > 0) {
                            tipText = toolT;
                        }
                    }
                }
            }

            TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex);
            Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex);

            // Now have to see if the component is a JComponent before
            // getting the tip
            if (component instanceof JComponent) {
                // Convert the event to the renderer's coordinate system
                Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false);
                p.translate(-cellRect.x, -cellRect.y);
                MouseEvent newEvent = new MouseEvent(component, event.getID(),
                                          event.getWhen(), event.getModifiers(),
                                          p.x, p.y,
                                          event.getXOnScreen(),
                                          event.getYOnScreen(),
                                          event.getClickCount(),
                                          event.isPopupTrigger(),
                                          MouseEvent.NOBUTTON);

                if (tipText == null) {
                    tipText = ((JComponent)component).getToolTipText(newEvent);
                }
                toolTip = ((JComponent)component).createToolTip();
            }
        }

        // No tip from the renderer get our own tip
        if (tipText == null)
            tipText = getToolTipText();

        if (tipText != null) {
            tipText = tipText.trim();
            if (tipText.length() > MAX_TOOLTIP_LENGTH &&
                !tipText.regionMatches(false, 0, "<html>", 0, 6)) {   // Do not cut HTML tooltips

                tipText = tipText.substring(0, MAX_TOOLTIP_LENGTH) + "...";
            }
        }
        return tipText;
    } finally {
        putClientProperty("ComputingTooltip", Boolean.FALSE);
    }
    //return super.getToolTipText(event);
}
 
Example 19
Project: Wilmersdorf_SER316   File: ProjectsPanel.java   View Source Code Vote up 4 votes
public void mouseClicked(MouseEvent e) {
	if (e.getClickCount() == 2)
		ppOpenProject_actionPerformed(null);
}
 
Example 20
Project: incubator-netbeans   File: DirectoryChooserUI.java   View Source Code Vote up 4 votes
/********* impl of MouseListener ***********/

@Override
public void mouseClicked(MouseEvent e) {
    final JTree tree = (JTree) e.getSource();
    Point p = e.getPoint();
    final int x = e.getX();
    final int y = e.getY();
    int row = tree.getRowForLocation(x, y);
    TreePath path = tree.getPathForRow(row);
    
    if (path != null) {
        
        DirectoryNode node = (DirectoryNode) path.getLastPathComponent();
        newFolderAction.enable(node.getFile());
    
        if (SwingUtilities.isLeftMouseButton(e) && (e.getClickCount() == 2)) {
            handleDblClick(node);
            return;
        }
        
        // handles click to rename feature
        if (SwingUtilities.isLeftMouseButton(e) && (e.getClickCount() == 1)) {
            if (pathToRename != null) {
                if (dblClickTimer != null) {
                    handleDblClick(node);
                    return;
                }
                // start slow click rename timer
                renameTimer = new Timer(800, this);
                renameTimer.setRepeats(false);
                renameTimer.start();
                startDblClickTimer();
            }
        }
        
        startDblClickTimer();
        ((DirectoryTreeModel) tree.getModel()).nodeChanged(node);
        if (row == 0) {
            tree.revalidate();
            tree.repaint();
        }
    }
}