public void mousePressed(MouseEvent evt) { requestFocus(); // Focus events not fired sometimes? setCaretVisible(true); focusedComponent = JEditTextArea.this; if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0 && popup != null) { popup.show(painter, evt.getX(), evt.getY()); return; } int line = yToLine(evt.getY()); int offset = xToOffset(line, evt.getX()); int dot = getLineStartOffset(line) + offset; switch (evt.getClickCount()) { case 1: doSingleClick(evt, line, offset, dot); break; case 2: // It uses the bracket matching stuff, so // it can throw a BLE try { doDoubleClick(evt, line, offset, dot); } catch (BadLocationException bl) { bl.printStackTrace(); } break; case 3: doTripleClick(evt, line, offset, dot); break; } }
/** Select or grow image when clicked. */ public void mousePressed(MouseEvent e) { Dimension size = fComponent.getSize(); if (e.getX() >= size.width - 7 && e.getY() >= size.height - 7 && getSelectionState() == 2) { // Click in selected grow-box: if (DEBUG) System.out.println("ImageView: grow!!! Size=" + fWidth + "x" + fHeight); Point loc = fComponent.getLocationOnScreen(); fGrowBase = new Point(loc.x + e.getX() - fWidth, loc.y + e.getY() - fHeight); fGrowProportionally = e.isShiftDown(); } else { // Else select image: fGrowBase = null; JTextComponent comp = (JTextComponent) fContainer; int start = fElement.getStartOffset(); int end = fElement.getEndOffset(); int mark = comp.getCaret().getMark(); int dot = comp.getCaret().getDot(); if (e.isShiftDown()) { // extend selection if shift key down: if (mark <= start) comp.moveCaretPosition(end); else comp.moveCaretPosition(start); } else { // just select image, without shift: if (mark != start) comp.setCaretPosition(start); if (dot != end) comp.moveCaretPosition(end); } } }
public void mouseClicked(MouseEvent e) { int x; int y; e.consume(); if (mouseEventsEnabled) { x = Math.round(e.getX() / scale); y = Math.round(e.getY() / scale); // allow for the canvas margin y -= margin; // System.out.println("Mouse Click: (" + x + ", " + y + ")"); if (e.getClickCount() < 2) { if (nativeSelectItem(x, y)) { parentFTAFrame.updateFrame(); } } else { if (nativeSelectItem(x, y)) { parentFTAFrame.updateFrame(); } editSelected(); parentFTAFrame.updateFrame(); } if (focusEventsEnabled) { // tell the main Canvas to point to this coordinate parentFTAFrame.setCanvasFocus(x, y); } } }
public void mousePressed(MouseEvent e) { int x = e.getX(), y = e.getY(); pressX = lastX = x; pressY = lastY = y; first = findFigureElement(x, y); if (first == null) { point1 = addPoint(x, y); } }
public void mouseDragged(MouseEvent e) { int x = e.getX(), y = e.getY(), dx = lastX - x, dy = lastY - y; lastX = x; lastY = y; if (first == null) { Line line = addLine(point1, new Point(x, y)); if (line != null) { canvas.add(line.getP2()); first = line.getP2(); canvas.add(line); } } else { first.move(-dx, -dy); } repaint(); }
/** Resize image if initial click was in grow-box: */ public void mouseDragged(MouseEvent e) { if (fGrowBase != null) { Point loc = fComponent.getLocationOnScreen(); int width = Math.max(2, loc.x + e.getX() - fGrowBase.x); int height = Math.max(2, loc.y + e.getY() - fGrowBase.y); if (e.isShiftDown() && fImage != null) { // Make sure size is proportional to actual image size: float imgWidth = fImage.getWidth(this); float imgHeight = fImage.getHeight(this); if (imgWidth > 0 && imgHeight > 0) { float prop = imgHeight / imgWidth; float pwidth = height / prop; float pheight = width * prop; if (pwidth > width) width = (int) pwidth; else height = (int) pheight; } } resize(width, height); } }
public void mouseReleased(MouseEvent aEvent) { if (aEvent.isPopupTrigger()) contextMenu.show((Component) aEvent.getSource(), aEvent.getX(), aEvent.getY()); }
public void mouseDragged(MouseEvent evt) { if (popup != null && popup.isVisible()) return; setSelectionRectangular((evt.getModifiers() & InputEvent.CTRL_MASK) != 0); select(getMarkPosition(), xyToOffset(evt.getX(), evt.getY())); }
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { popup.show(e.getComponent(), e.getX(), e.getY()); } }
void jTextPaneDisplayMessages_mouseClicked(MouseEvent e) { if ((e.getModifiers() & Event.META_MASK) == Event.META_MASK) { jPopupMenuMessageArea.show(jTextPaneDisplayMessages, e.getX(), e.getY()); } }
/** Checks to see if the event was to show the popup menu */ private void maybeShowPopup(MouseEvent e) { if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) { popup.show(userList, e.getX(), e.getY()); } }