public void mouseReleased(MouseEvent e) { lastInteractionTime = System.currentTimeMillis(); if (enabled && !readOnly && lastPressEvent != null && dragInProgress) { if (enableMouseDrags && !e.getPoint().equals(lastPressEvent.getPoint())) { dragInProgress = false; // Generate the command string String s = "Mouse " + MouseCommand.MOUSE_DRAG; // Insert the button identifier if other than left button was pressed if (e.getButton() != MouseEvent.BUTTON1) { s += " " + MouseCommand.PARAM_BUTTON_SHORT + "=" + parser.buttonToString(e.getButton()); } // Insert modifiers if there are any String modifiers = parser.modifiersToString(e.getModifiers()); if (modifiers.length() > 0) { s += " " + MouseCommand.PARAM_MODIFIER + "=" + modifiers; } // Generate coordinates s += " " + MouseCommand.PARAM_FROM + "=" + parser.pointToString(lastPressEvent.getPoint()); s += " " + MouseCommand.PARAM_TO + "=" + parser.pointToString(e.getPoint()); // Insert the command to the current editor insertLine(s, false, true, false); insertEvent(e); } } }
@Override public final void mousePressed(final MouseEvent e) { if (!isEnabled() || !isFocusable()) return; requestFocusInWindow(); cursor(true); if (SwingUtilities.isMiddleMouseButton(e)) copy(); final boolean marking = e.isShiftDown(); final boolean nomark = !text.marked(); if (SwingUtilities.isLeftMouseButton(e)) { final int c = e.getClickCount(); if (c == 1) { // selection mode if (marking && nomark) text.startMark(); rend.select(scroll.pos(), e.getPoint(), marking); } else if (c == 2) { text.selectWord(); } else { text.selectLine(); } } else if (nomark) { rend.select(scroll.pos(), e.getPoint(), false); } }
@Override public void mouseMoved(MouseEvent e) { final MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, getParent()); final boolean insideRec = getBounds().contains(event.getPoint()); boolean buttonsNotPressed = (e.getModifiersEx() & (InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON2_DOWN_MASK | InputEvent.BUTTON3_DOWN_MASK)) == 0; if (!myPopupIsShowing && insideRec && buttonsNotPressed) { showPopup(null, false); } else if (myPopupIsShowing && !insideRec) { final Component over = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY()); JPopupMenu popup = myUnderPopup.isShowing() ? myUnderPopup : myAbovePopup; if (over != null && popup.isShowing()) { final Rectangle rec = new Rectangle(popup.getLocationOnScreen(), popup.getSize()); int delta = 15; rec.x -= delta; rec.width += delta * 2; rec.y -= delta; rec.height += delta * 2; final Point eventPoint = e.getPoint(); SwingUtilities.convertPointToScreen(eventPoint, e.getComponent()); if (rec.contains(eventPoint)) { return; } } closePopup(); } }
/** * Defaults to typical marquee behaviour unless a flow relation is being drawn. In that case, each * drag event will redraw a line from the mouse cursor to the source port. If there is a valid * incoming port under the mouse, this will also be highlighted to identify that a valid flow may * be drawn upon a mouse release event. */ public void mouseDragged(MouseEvent event) { if (paletteBar.getState() == Palette.SelectionState.MARQUEE) { super.mouseDragged(event); return; } if (state == State.DRAWING_FLOW_RELATION) { if (sourcePort != null) { setCurrentPoint(getNet().snap(event.getPoint())); paintPotentialFlow(); PortView portUnderMouse = getPortViewAt(event.getPoint()); if (portUnderMouse != null && portUnderMouse != sourcePort && connectionAllowable(sourcePort, portUnderMouse) && acceptsIncomingFlows(portUnderMouse)) { if (portUnderMouse != targetPort) { targetPort = portUnderMouse; getOverlay().setTarget(net.toScreen(targetPort.getBounds())); } } if (portUnderMouse == null) { targetPort = null; getOverlay().setTarget(null); } } event.consume(); } }
@Override @SuppressWarnings({"deprecation", "unchecked"}) // FIXME in Java7 public void mousePressed(MouseEvent e) { if (!enabled && e.getClickCount() == 1 && !e.isConsumed()) { enabled = true; } if (enabled) { JList source = (JList) e.getSource(); if ((e.getButton() == MouseEvent.BUTTON3 || e.isPopupTrigger())) { int index = source.locationToIndex(e.getPoint()); BuildableType type = (BuildableType) source.getModel().getElementAt(index); getGUI().showColopediaPanel(type.getId()); } else if ((e.getClickCount() > 1 && !e.isConsumed())) { DefaultListModel model = (DefaultListModel) buildQueueList.getModel(); if (source.getSelectedIndex() == -1) { source.setSelectedIndex(source.locationToIndex(e.getPoint())); } for (Object type : source.getSelectedValues()) { if (add) { model.addElement(type); } else { model.removeElement(type); } } updateAllLists(); } } }
public String getToolTipText(MouseEvent e) { int r = rowAtPoint(e.getPoint()); int c = columnAtPoint(e.getPoint()); Object value; try { value = getValueAt(r, c); } catch (Exception e1) { // If we encounter a row that should not actually exist and therefore // has a null value. Just return an empty string for the tooltip. return ""; } String tooltipValue = null; if (value instanceof JLabel) { tooltipValue = ((JLabel) value).getToolTipText(); } if (value instanceof JLabel && tooltipValue == null) { tooltipValue = ((JLabel) value).getText(); } else if (value != null && tooltipValue == null) { tooltipValue = value.toString(); } else if (tooltipValue == null) { tooltipValue = ""; } return GraphicUtils.createToolTip(tooltipValue); }
/** * A chat room was selected. Opens the chat room in the chat window. * * @param e the <tt>MouseEvent</tt> instance containing details of the event that has just * occurred. */ public void mousePressed(MouseEvent e) { // Select the object under the right button click. if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0 || (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || (e.isControlDown() && !e.isMetaDown())) { int ix = this.chatRoomList.rowAtPoint(e.getPoint()); if (ix != -1) { this.chatRoomList.setRowSelectionInterval(ix, ix); } } Object o = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow()); Point selectedCellPoint = e.getPoint(); SwingUtilities.convertPointToScreen(selectedCellPoint, chatRoomList); if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { JPopupMenu rightButtonMenu; if (o instanceof ChatRoomWrapper) rightButtonMenu = new ChatRoomRightButtonMenu((ChatRoomWrapper) o); else return; rightButtonMenu.setInvoker(this); rightButtonMenu.setLocation(selectedCellPoint); rightButtonMenu.setVisible(true); } }
/** * This method is called when the mouse is pressed in the JToolBar. If the press doesn't occur * in a place where it causes the JToolBar to be dragged, it returns. Otherwise, it starts a * drag session. * * @param e The MouseEvent. */ public void mousePressed(MouseEvent e) { if (!toolBar.isFloatable()) return; Point ssd = e.getPoint(); Insets insets = toolBar.getInsets(); // Verify that this click occurs in the top inset. if (toolBar.getOrientation() == SwingConstants.HORIZONTAL) { if (e.getX() > insets.left) return; } else { if (e.getY() > insets.top) return; } origin = new Point(0, 0); if (toolBar.isShowing()) SwingUtilities.convertPointToScreen(ssd, toolBar); if (!(SwingUtilities.getAncestorOfClass(Window.class, toolBar) instanceof UIResource)) // Need to know who keeps the toolBar if it gets dragged back into it. origParent = toolBar.getParent(); if (toolBar.isShowing()) SwingUtilities.convertPointToScreen(origin, toolBar); isDragging = true; if (dragWindow != null) dragWindow.setOffset(new Point(cachedBounds.width / 2, cachedBounds.height / 2)); dragTo(e.getPoint(), origin); }
private DeleteParameters getDeleteParameters(MouseEvent e, int modifiers) { // Note: CTRL is the only modifier that is checked in MouseMove, don't // forget updating it there boolean ctrl = (modifiers & ActionEvent.CTRL_MASK) != 0; boolean shift = (modifiers & ActionEvent.SHIFT_MASK) != 0; boolean alt = (modifiers & (ActionEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK)) != 0; DeleteParameters result = new DeleteParameters(); result.nearestNode = Main.map.mapView.getNearestNode(e.getPoint(), OsmPrimitive.isSelectablePredicate); if (result.nearestNode == null) { result.nearestSegment = Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive.isSelectablePredicate); if (result.nearestSegment != null) { if (shift) { result.mode = DeleteMode.segment; } else if (ctrl) { result.mode = DeleteMode.way_with_references; } else { result.mode = alt ? DeleteMode.way : DeleteMode.way_with_nodes; } } else { result.mode = DeleteMode.none; } } else if (ctrl) { result.mode = DeleteMode.node_with_references; } else { result.mode = DeleteMode.node; } return result; }
/** * Open the popup menu. * * @param evt */ private void sampleCvTermsJTableMouseClicked( java.awt.event.MouseEvent evt) { // GEN-FIRST:event_sampleCvTermsJTableMouseClicked if (evt.getButton() == 3) { int row = sampleCvTermsJTable.rowAtPoint(evt.getPoint()); int column = sampleCvTermsJTable.columnAtPoint(evt.getPoint()); sampleCvTermsJTable.changeSelection(row, column, false, false); this.moveUpJMenuItem.setEnabled(true); this.moveDownJMenuItem.setEnabled(true); if (row == sampleCvTermsJTable.getRowCount() - 1) { this.moveDownJMenuItem.setEnabled(false); } if (row == 0) { this.moveUpJMenuItem.setEnabled(false); } popupJMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } else if (evt.getButton() == 1 && evt.getClickCount() == 2) { editJMenuItemActionPerformed(null); } } // GEN-LAST:event_sampleCvTermsJTableMouseClicked
public void mousePressed(MouseEvent e) { dragType = 0; Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), getContentPane()); /*if (p.y < 10){ dragType |= DRAG_TOP; } if (p.x < 5){ dragType |= DRAG_LEFT; } if (p.x > getWidth() - 5){ dragType |= DRAG_RIGHT; } if (p.y > getHeight() - 5){ dragType |= DRAG_BOTTOM; }*/ if (p.y < title.getY() + title.getHeight()) { dragType |= DRAG_TOP; } if (p.x < left.getX() + left.getWidth()) { dragType |= DRAG_LEFT; } if (p.x >= right.getX()) { // getWidth() - 5){ dragType |= DRAG_RIGHT; } if (p.y >= bottom.getY()) { dragType |= DRAG_BOTTOM; } lastPoint = e.getPoint(); SwingUtilities.convertPointToScreen(lastPoint, e.getComponent()); }
public void mouseDragged(MouseEvent evt) { Graphics g = canvas.getGraphics(); g.setColor(color); if (type == 0) { g.setXORMode(canvas.getBackground()); g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y); end = evt.getPoint(); g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y); } else if (type == 1) { int radius; g.setXORMode(canvas.getBackground()); radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2)); g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius); end = evt.getPoint(); radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2)); g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius); } else if (type == 2) { g.setXORMode(canvas.getBackground()); g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y); end = evt.getPoint(); g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y); } }
public void mouseMoved(MouseEvent mouseEvent) { if (pointInComboBox(mouseEvent.getPoint())) { hoverUnderPoint(mouseEvent.getPoint()); } else if (isExpanded()) { toggle(); } }
public void mousePressed(java.awt.event.MouseEvent e) { if (e.isPopupTrigger()) { doPopup(e); return; } if (!org.nlogo.awt.Mouse.hasButton1(e)) { return; } // this is so the user can use action keys to control buttons // - ST 8/6/04,8/31/04 this.requestFocus(); java.awt.Point p = e.getPoint(); java.awt.Rectangle rect = this.getBounds(); p.x += rect.x; p.y += rect.y; if (!rect.contains(p)) { return; } unselectWidgets(); startDragPoint = e.getPoint(); if (widgetCreator == null) { return; } Widget widget = widgetCreator.getWidget(); if (widget == null) { return; } addWidget(widget, e.getX(), e.getY(), true, false); revalidate(); }
/** @return the grid component that contains the given mouse ponit. */ private GridComponent getComponent(MouseEvent e) { DesignGridOverlay overlay = (DesignGridOverlay) m_comp.getChildOverlay(); Point local_pt = SwingUtilities.convertPoint((Component) e.getSource(), e.getPoint(), (Component) overlay); GridComponent cell = overlay.getCell(local_pt); if (cell == null) { DesignFormComponent parent = (DesignFormComponent) getParentForm(m_comp); if (parent != null) { DesignGridOverlay parentoverlay = (DesignGridOverlay) parent.getChildOverlay(); local_pt = SwingUtilities.convertPoint( (Component) e.getSource(), e.getPoint(), (Component) parentoverlay); int y = local_pt.y; int x = local_pt.x; if (x >= m_comp.getCellX() && x <= m_comp.getCellX() + m_comp.getCellWidth() && y >= m_comp.getCellY() && y <= m_comp.getCellY() + m_comp.getCellHeight()) { cell = m_comp; } } } return cell; }
@Override public void mouseMoved(MouseEvent e) { if (game.state == Game.MENU) { if (drawSubmenuScreen == -1) { // Get rectangle which has been moved over for (int i = 0; i < NUM_BOXES; i++) { if (boxs[i].getRect().contains(e.getPoint())) { boxs[i].setColor(Color.RED, Color.WHITE); } else { boxs[i].setColor(Color.GRAY, Color.BLACK); } } if (subMenuVisible) { for (int i = 0; i < NUM_BOXES; i++) { if (subBoxs[i].getRect().contains(e.getPoint())) { subBoxs[i].setColor(Color.RED, Color.WHITE); } else { subBoxs[i].setColor(Color.GRAY, Color.BLACK); } } } } else { // In submenu screen for (int i = 0; i < NUM_SUB_BOXES; i++) { if (subMenuBoxs[i].getRect().contains(e.getPoint())) { subMenuBoxs[i].setColor(Color.RED, Color.BLACK); } else { subMenuBoxs[i].setColor(Color.BLACK, Color.WHITE); } } } } }
@Override public void mouseReleased(MouseEvent e) { log.info("released: " + e); if (point1 != null && point2 != null) { if (draggedNode == null) { ZNode z = findZNodeAt(e.getPoint()); if (z == null) { createSubNode(e.getPoint()); } else dragged(z); } else if (e.getPoint().y >= display.getHeight() - 40) { final ZTask task = taskList.getTaskAt(e.getPoint().x, 20); if (task == null) { // TODO: show confirmation? synchronized (zNodes) { zNodes.remove(draggedNode); } } else task.add(draggedNode); draggedNode = null; } else { draggedNode.getLocation().setLocation(translateToZNodePoint(point2)); updateSubLocations(draggedNode, true, draggedNode.getLocation()); draggedNode = null; } point1 = point2 = null; } }
/** * Changes the cursor into a hand cursor if the table cell contains an HTML link. * * @param evt */ private void proteinMatchTableMouseMoved( java.awt.event.MouseEvent evt) { // GEN-FIRST:event_proteinMatchTableMouseMoved int row = proteinMatchTable.rowAtPoint(evt.getPoint()); int column = proteinMatchTable.columnAtPoint(evt.getPoint()); proteinMatchTable.setToolTipText(null); if (column == 2 && proteinMatchTable.getValueAt(row, column) != null) { String tempValue = (String) proteinMatchTable.getValueAt(row, column); if (tempValue.lastIndexOf("<html>") != -1) { this.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); } else { this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); } } else if (column == proteinMatchTable.getColumn("Description").getModelIndex() && proteinMatchTable.getValueAt(row, column) != null) { if (GuiUtilities.getPreferredWidthOfCell(proteinMatchTable, row, column) > proteinMatchTable.getColumn("Description").getWidth()) { proteinMatchTable.setToolTipText("" + proteinMatchTable.getValueAt(row, column)); } this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); } else { this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); } } // GEN-LAST:event_proteinMatchTableMouseMoved
@Override public void mouseClicked(MouseEvent arg0) { int col = tableFiles.columnAtPoint(arg0.getPoint()); if (col == 0) { int row = tableFiles.rowAtPoint(arg0.getPoint()); row = tableFiles.convertRowIndexToModel(row); MediaFile mf = mediaFileEventList.get(row); // open the video file in the desired player if (mf.isVideo()) { try { TmmUIHelper.openFile(mf.getFile()); } catch (Exception e) { LOGGER.error("open file", e); MessageManager.instance.pushMessage( new Message( MessageLevel.ERROR, mf, "message.erroropenfile", new String[] {":", e.getLocalizedMessage()})); } } // open the graphic in the lightbox if (mf.isGraphic()) { MainWindow.getActiveInstance() .createLightbox(mf.getPath() + File.separator + mf.getFilename(), ""); } } }
@Override public void mouseClicked(MouseEvent e) { if (ledGreen.contains(e.getPoint())) { if (ledP == false) { ledP = true; chipP = false; wireP = false; wireStep2 = false; } else { ledP = false; } } if (ledRed.contains(e.getPoint())) { if (ledP == false) { ledP = true; chipP = false; wireP = false; wireStep2 = false; } else { ledP = false; } } if (ledBlue.contains(e.getPoint())) { if (ledP == false) { ledP = true; chipP = false; wireP = false; wireStep2 = false; } else { ledP = false; } } }
private DeleteParameters getDeleteParameters(MouseEvent e, int modifiers) { updateKeyModifiers(modifiers); DeleteParameters result = new DeleteParameters(); result.nearestNode = Main.map.mapView.getNearestNode(e.getPoint(), OsmPrimitive.isSelectablePredicate); if (result.nearestNode == null) { result.nearestSegment = Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive.isSelectablePredicate); if (result.nearestSegment != null) { if (shift) { result.mode = DeleteMode.segment; } else if (ctrl) { result.mode = DeleteMode.way_with_references; } else { result.mode = alt ? DeleteMode.way : DeleteMode.way_with_nodes; } } else { result.mode = DeleteMode.none; } } else if (ctrl) { result.mode = DeleteMode.node_with_references; } else { result.mode = DeleteMode.node; } return result; }
public void mouseClicked(MouseEvent e) { if (e.isPopupTrigger()) { processPopupTrigger(e); return; } // if (e.) final int col = entryTable.columnAtPoint(e.getPoint()), row = entryTable.rowAtPoint(e.getPoint()); if (col < PAD) { BibtexEntry entry = sortedEntries.get(row); BasePanel p = entryHome.get(entry); switch (col) { case FILE_COL: Object o = entry.getField(GUIGlobals.FILE_FIELD); if (o != null) { FileListTableModel tableModel = new FileListTableModel(); tableModel.setContent((String) o); if (tableModel.getRowCount() == 0) return; FileListEntry fl = tableModel.getEntry(0); (new ExternalFileMenuItem( frame, entry, "", fl.getLink(), null, p.metaData(), fl.getType())) .actionPerformed(null); } break; case URL_COL: Object link = entry.getField("url"); try { if (link != null) Util.openExternalViewer(p.metaData(), (String) link, "url"); } catch (IOException ex) { ex.printStackTrace(); } break; } } }
/** * If the user has signalled the opening of a context menu, the event gets redirected to this * method. Here we open a file link menu if the user is pointing at a file link icon. Otherwise * a general context menu should be shown. * * @param e The triggering mouse event. */ public void processPopupTrigger(MouseEvent e) { BibtexEntry entry = sortedEntries.get(entryTable.rowAtPoint(e.getPoint())); BasePanel p = entryHome.get(entry); int col = entryTable.columnAtPoint(e.getPoint()); JPopupMenu menu = new JPopupMenu(); int count = 0; if (col == FILE_COL) { // We use a FileListTableModel to parse the field content: Object o = entry.getField(GUIGlobals.FILE_FIELD); FileListTableModel fileList = new FileListTableModel(); fileList.setContent((String) o); // If there are one or more links, open the first one: for (int i = 0; i < fileList.getRowCount(); i++) { FileListEntry flEntry = fileList.getEntry(i); String description = flEntry.getDescription(); if ((description == null) || (description.trim().length() == 0)) description = flEntry.getLink(); menu.add( new ExternalFileMenuItem( p.frame(), entry, description, flEntry.getLink(), flEntry.getType().getIcon(), p.metaData(), flEntry.getType())); count++; } } if (count > 0) menu.show(entryTable, e.getX(), e.getY()); }
/** If the correct button is hold, draw the rectangle. */ @Override public void mouseDragged(MouseEvent e) { int buttonPressed = e.getModifiersEx() & (MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON3_DOWN_MASK); if (buttonPressed != 0) { if (mousePosStart == null) { mousePosStart = mousePos = e.getPoint(); } if (!lassoMode) { paintRect(); } } if (buttonPressed == MouseEvent.BUTTON1_DOWN_MASK) { mousePos = e.getPoint(); if (lassoMode) { paintLasso(); } else { paintRect(); } } else if (buttonPressed == (MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON3_DOWN_MASK)) { mousePosStart.x += e.getX() - mousePos.x; mousePosStart.y += e.getY() - mousePos.y; mousePos = e.getPoint(); paintRect(); } }
/* * Handles the checkbox selection process. Uses the bounds property of the * check box within the selected cell to determine whether the checkbox should * be selected or not **/ public void mouseReleased(MouseEvent e) { if (list == null || list.getSelectedIndex() == -1 || !isEnabled(list.locationToIndex(e.getPoint()))) { return; } int[] indices = list.getSelectedIndices(); // get the current relative position of the check box // rect = box.getBounds(rect); for (int i = 0; i < indices.length; i++) { // get the current relative position of the check box int loc = list.locationToIndex(e.getPoint()); rect = list.getCellBounds(loc, loc); // ensure the point clicked in within the checkBox /*if(e.getX() < (rect.getX() + 20) ) { selState[indices[i]] = !selState[indices[i]]; setSelStateList(selState); } */ } list.revalidate(); list.repaint(); }
@Override public final void mousePressed(final MouseEvent e) { if (!isEnabled() || !isFocusable()) return; requestFocusInWindow(); caret(true); if (SwingUtilities.isMiddleMouseButton(e)) copy(); final boolean shift = e.isShiftDown(); final boolean selected = editor.selected(); if (SwingUtilities.isLeftMouseButton(e)) { final int c = e.getClickCount(); if (c == 1) { // selection mode if (shift) editor.startSelection(true); select(e.getPoint(), !shift); } else if (c == 2) { editor.selectWord(); } else { editor.selectLine(); } } else if (!selected) { select(e.getPoint(), true); } }
/** * Mouse CLICKED event handling * * @param e the event * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) */ public void mouseClicked(MouseEvent e) { // Right click management if ((e.getClickCount() == 1 && SwingUtilities.isRightMouseButton(e)) || e.isPopupTrigger()) { int clickedRow = ((JTable) e.getSource()).rowAtPoint(e.getPoint()); // Does nothing if no variable selected if (clickedRow != -1) { // Right click ? We force the selection of the current row table.setRowSelectionInterval(clickedRow, clickedRow); table.setEditingRow(clickedRow); displayContextMenu(); } } if (e.getClickCount() >= 2) { int clickedRow = ((JTable) e.getSource()).rowAtPoint(e.getPoint()); if (clickedRow != -1) { String variableName = table.getValueAt(clickedRow, BrowseVar.NAME_COLUMN_INDEX).toString(); String variableVisibility = ((JTable) e.getSource()) .getValueAt( ((JTable) e.getSource()).getSelectedRow(), BrowseVar.VISIBILITY_COLUMN_INDEX) .toString(); SwingScilabVariableBrowser.this.startEditVar(variableVisibility, variableName); } } }
@Override public void mouseMoved(MouseEvent e) { if (e.getSource() == browseTree) { browseTreeRenderer.setMousePointInTree(e.getPoint()); TreePath path = browseTree.getPathForLocation(e.getX(), e.getY()); if (path != null) { if (!(path.getLastPathComponent() instanceof ListableEntry)) return; ListableEntry fse = (ListableEntry) path.getLastPathComponent(); if (fse != lastInspectedFSE || lastOnIcon != browseTreeRenderer.pointOnIcon(e.getPoint())) { long size = fse.getSize(); frame.setStatusHint(fse.getName() + ": " + Util.niceSize(size)); if (lastInspectedFSE != null) browseTree.repaint(browseTree.getPathBounds(lastInspectedFSE.getPath())); lastInspectedFSE = fse; lastOnIcon = browseTreeRenderer.pointOnIcon(e.getPoint()); browseTree.repaint(browseTree.getPathBounds(path)); } } else { if (lastInspectedFSE != null) { Rectangle r = browseTree.getPathBounds(lastInspectedFSE.getPath()); lastInspectedFSE = null; browseTree.repaint(r); } } } }
@Override public void mousePressed(MouseEvent e) { // добавить новый квадрат, если курсор находится вне квадрата current = find(e.getPoint()); if (current == null) { add(e.getPoint()); } }
public void mousePressed(MouseEvent mouseEvent) { if (pointInComboBox(mouseEvent.getPoint())) { setSelectedUnderPoint(mouseEvent.getPoint()); toggle(); } else { setExpanded(false); } }