コード例 #1
0
ファイル: LJ3MDApp.java プロジェクト: eskilj/mvp
 public void mousePressed(MouseEvent e) {
   mouseX = e.getX();
   mouseY = e.getY();
   // consume this event so that it will not be processed
   // in the default manner
   e.consume();
 }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   FinderTableModel model = getDataModel();
   ICFSecurityISOTimezoneObj o =
       (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o);
   ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   if (frame == null) {
     return;
   }
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
コード例 #3
0
    public void mouseClicked(MouseEvent ev) {
      Window w = (Window) ev.getSource();
      Frame f = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else {
        return;
      }

      Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane());

      int state = f.getExtendedState();
      if (getTitlePane() != null && getTitlePane().contains(convertedPoint)) {
        if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
          if (f.isResizable()) {
            if ((state & Frame.MAXIMIZED_BOTH) != 0) {
              f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH);
            } else {
              f.setExtendedState(state | Frame.MAXIMIZED_BOTH);
            }
            return;
          }
        }
      }
    }
コード例 #4
0
 public void mouseDragged(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   boolean oldMouseOverButton = mMouseOverButton;
   if (mPressedButton != -1) mMouseOverButton = mRect[mPressedButton].contains(x, y);
   if (mMouseOverButton ^ oldMouseOverButton) repaint();
 }
コード例 #5
0
 /** Handles mouse move events. The event is delegated to the currently active tool. */
 public void mouseMoved(MouseEvent e) {
   try {
     tool().mouseMove(e, e.getX(), e.getY());
   } catch (Throwable t) {
     handleMouseEventException(t);
   }
 }
コード例 #6
0
    private void adjustFocusAndSelection(MouseEvent e) {
      if (shouldIgnore(e)) {
        return;
      }

      Point p = e.getPoint();
      int row = grid.rowAtPoint(p);
      int column = grid.columnAtPoint(p);

      // The autoscroller can generate drag events outside range.
      if ((column == -1) || (row == -1)) {
        System.err.println("Out of bounds");
        return;
      }

      if (grid.editCellAt(row, column, e)) {
        setDispatchComponent(e);
        repostEvent(e);
      } else {
        grid.requestFocus();
      }

      GridCellEditor editor = grid.getCurrentCellEditor();
      if (editor == null || editor.shouldSelectCell(e)) {
        // Update selection model
        setValueIsAdjusting(true);
        grid.changeSelection(row, column, e.isControlDown(), e.isShiftDown());
      }
    }
コード例 #7
0
ファイル: ImageEditMode.java プロジェクト: BKJackson/idh
 private void onMouseUp(MouseEvent e) {
   if (hasMotionListener()) {
     changeSelectedPoint(e.getX(), e.getY());
     removeMotionListener();
   }
   updateAll();
 }
コード例 #8
0
 public void mouseEvt(MouseEvent evt) {
   if (evt.isPopupTrigger()) {
     propDialog.setVisible(true);
     propDialog.toFront();
     evt.consume();
   }
 }
コード例 #9
0
  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);
      }
    }
  }
コード例 #10
0
  /**
   * This is called when the user presses the mouse anywhere in the panel. There are three possible
   * responses, depending on where the user clicked: Change the current color, clear the drawing, or
   * start drawing a curve. (Or do nothing if user clicks on the border.)
   */
  public void mousePressed(MouseEvent evt) {
    int x = evt.getX(); // x-coordinate where the user clicked.
    int y = evt.getY(); // y-coordinate where the user clicked.

    int width = runner.content.getWidth(); // Width of the panel.
    int height = runner.content.getHeight(); // Height of the panel.

    if (dragging == true) // Ignore mouse presses that occur
    return; //    when user is already drawing a curve.
    //    (This can happen if the user presses
    //    two mouse buttons at the same time.)
    // ***like left button is down+dragging but you click the right button
    if (x > width - 53) {
      if (y > height - 53) {
        runner.content.lines =
            new ArrayList<Line>(); // *** lines now points to a new,  empty ArrayList
        runner.content.repaint(); //  Clicked on "CLEAR button".
      } else {
        runner.content.changeColor(y); // Clicked on the color palette.
        runner.content.repaint(); // ***added this to update the highlighted square of color
      }
    } else if (x > 3 && x < width - 56 && y > 3 && y < height - 3) {
      // The user has clicked on the white drawing area.
      // Start drawing a curve from the point (x,y).
      prevX = x;
      prevY = y;
      dragging = true;
    }
  } // end mousePressed()
コード例 #11
0
  /**
   * Called whenever the user moves the mouse while a mouse button is held down. If the user is
   * drawing, draw a line segment from the previous mouse location to the current mouse location,
   * and set up prevX and prevY for the next call. Note that in case the user drags outside of the
   * drawing area, the values of x and y are "clamped" to lie within this area. This avoids drawing
   * on the color palette or clear button.
   */
  public void mouseDragged(MouseEvent evt) {
    //	System.out.println("mouseDragged!");
    if (dragging == false) return; // Nothing to do because the user isn't drawing.

    int x = evt.getX(); // x-coordinate of mouse.
    int y = evt.getY(); // y-coordinate of mouse.

    if (x < 3) // Adjust the value of x,
    x = 3; //   to make sure it's in
    if (x > runner.content.getWidth() - 57) //   the drawing area.
    x = runner.content.getWidth() - 57;

    if (y < 3) // Adjust the value of y,
    y = 3; //   to make sure it's in
    if (y > runner.content.getHeight() - 4) //   the drawing area.
    y = runner.content.getHeight() - 4;

    runner.content.lines.add(
        new Line(
            prevX,
            prevY,
            x,
            y,
            runner
                .content
                .currentColor)); // **** simply add the line to the ArrayList, will be drawn later
    runner.content
        .repaint(); // ***Have System call paintComponent(), otherwise lines won't show up until you
    // clicked the
    // the next color
    prevX = x; // Get ready for the next line segment in the curve.
    prevY = y;
  } // end mouseDragged()
コード例 #12
0
 public void mouseDragged(MouseEvent e) {
   if (m_draggedFrom != Chess.NO_SQUARE) {
     m_draggedX = e.getX();
     m_draggedY = e.getY();
     repaint();
   }
 }
コード例 #13
0
 @Override
 public void mouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2) {
     doubleClicked((JComponent) e.getSource());
   }
   super.mouseClicked(e);
 }
コード例 #14
0
ファイル: JImage.java プロジェクト: RussTedrake/lcm
    public void mouseDragged(MouseEvent e) {
      int mods = e.getModifiersEx();
      Point dragEnd = e.getPoint();
      boolean shift = (mods & MouseEvent.SHIFT_DOWN_MASK) > 0;
      boolean ctrl = (mods & MouseEvent.CTRL_DOWN_MASK) > 0;
      boolean alt = shift & ctrl;
      ctrl = ctrl & (!alt);
      shift = shift & (!alt);
      boolean nomods = !(shift | ctrl | alt);

      if (dragBegin == null) dragBegin = dragEnd;

      nodrag = false;

      if ((mods & InputEvent.BUTTON3_DOWN_MASK) > 0 || true) {
        double dx = dragEnd.getX() - dragBegin.getX();
        double dy = dragEnd.getY() - dragBegin.getY();

        synchronized (JImage.this) {
          t.preConcatenate(AffineTransform.getTranslateInstance(dx, dy));
        }

        dragBegin = dragEnd;
        repaint();
      }
    }
コード例 #15
0
    public void mouseClicked(MouseEvent e) {
      JTableHeader h = (JTableHeader) e.getSource();
      TableColumnModel columnModel = h.getColumnModel();
      int viewColumn = columnModel.getColumnIndexAtX(e.getX());
      int column = columnModel.getColumn(viewColumn).getModelIndex();
      if (column != -1) {
        sorting_column = column;

        // 0 == priority icon column
        // 4 == priority text column
        if (column == 0) sorting_column = 4;

        if (e.isControlDown()) sorting_column = -1;
        else opposite = !opposite;

        TaskTable treetable = ((TaskTable) h.getTable());

        // java.util.Collection expanded = treetable.getExpandedTreeNodes();

        treetable.tableChanged();
        // treetable.setExpandedTreeNodes(expanded);
        // h.updateUI();
        h.resizeAndRepaint();
      }
    }
コード例 #16
0
 protected void processMouseEvent(MouseEvent e) {
   MouseEvent transformedEvent = transformMouseEvent(e);
   switch (e.getID()) {
     case MouseEvent.MOUSE_ENTERED:
       if (mouseDraggedComponent == null || mouseCurrentComponent == mouseDraggedComponent) {
         dispatchMouseEvent(transformedEvent);
       }
       break;
     case MouseEvent.MOUSE_EXITED:
       if (mouseEnteredComponent != null) {
         dispatchMouseEvent(
             createEnterExitEvent(mouseEnteredComponent, MouseEvent.MOUSE_EXITED, e));
         mouseEnteredComponent = null;
       }
       break;
     case MouseEvent.MOUSE_RELEASED:
       if (mouseDraggedComponent != null && e.getButton() == MouseEvent.BUTTON1) {
         transformedEvent.setSource(mouseDraggedComponent);
         mouseDraggedComponent = null;
       }
       dispatchMouseEvent(transformedEvent);
       break;
     default:
       dispatchMouseEvent(transformedEvent);
   }
   super.processMouseEvent(e);
 }
コード例 #17
0
 // Die Methoden des Interface MouseMotionListener implementieren
 public void mouseDragged(MouseEvent e) {
   // Die Koordinaten des Mausklicks lesen
   int x = e.getX();
   int y = e.getY();
   // und mit der Maus malen
   g.fillRect(x, y, 3, 3);
 }
コード例 #18
0
 private void dispatchMouseEvent(MouseEvent event) {
   MouseListener[] mouseListeners = event.getComponent().getMouseListeners();
   for (MouseListener listener : mouseListeners) {
     // skip all ToolTipManager's related listeners
     if (!listener.getClass().getName().startsWith("javax.swing.ToolTipManager")) {
       switch (event.getID()) {
         case MouseEvent.MOUSE_PRESSED:
           listener.mousePressed(event);
           break;
         case MouseEvent.MOUSE_RELEASED:
           listener.mouseReleased(event);
           break;
         case MouseEvent.MOUSE_CLICKED:
           listener.mouseClicked(event);
           break;
         case MouseEvent.MOUSE_EXITED:
           listener.mouseExited(event);
           break;
         case MouseEvent.MOUSE_ENTERED:
           listener.mouseEntered(event);
           break;
         default:
           throw new AssertionError();
       }
     }
   }
 }
コード例 #19
0
  public void leftMouseReleased(MouseEvent e) {
    double x = e.getX();
    double y = e.getY();

    // If no start vertex selected or start vertex is virtual, do nothing
    if (startVertex == null || startVertex.isVirtual()) {
      displayFrame.controlFrame.updateDisplays(true);
      return;
    }
    endVertex =
        getSelectedVertex(
            x, y, displayFrame.getMainDiagramPanel(), displayFrame.getFreeVertexPanel());
    // If no end vertex selected, still do nothing
    if (endVertex == null) {
      displayFrame.controlFrame.updateDisplays(true);
      return;
    }
    // If mouse pressed and released within the same vertex, print vertex label
    if (endVertex == startVertex) {
      canCreateEdge = false;
      startVertex.setSelected(!startVertex.isSelected());
      displayFrame.controlFrame.updateDisplays(true);
      return;
    } else {
      addNewEdge();
    }
  }
コード例 #20
0
ファイル: BaseXEditor.java プロジェクト: godmar/basex
  @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);
    }
  }
コード例 #21
0
ファイル: StdDraw.java プロジェクト: ihordey/algorithms-4th
 /** This method cannot be called directly. */
 public void mousePressed(MouseEvent e) {
   synchronized (mouseLock) {
     mouseX = StdDraw.userX(e.getX());
     mouseY = StdDraw.userY(e.getY());
     mousePressed = true;
   }
 }
コード例 #22
0
ファイル: FTACanvas.java プロジェクト: jandcmoore/OpenFTA
  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);
      }
    }
  }
コード例 #23
0
 public void mouseClicked(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   int currentTabIndex = -1;
   int tabCount = tabPane.getTabCount();
   for (int i = 0; i < tabCount; i++) {
     if (rects[i].contains(x, y)) {
       currentTabIndex = i;
       break;
     } // if contains
   } // for i
   if (currentTabIndex >= 0) {
     Rectangle tabRect = rects[currentTabIndex];
     x = x - tabRect.x;
     y = y - tabRect.y;
     if ((x >= 5) && (x <= 15) && (y >= 5) && (y <= 15)) {
       try {
         tabbedPane.remove(currentTabIndex);
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     } // if
   } // if currentTabIndex >= 0
   System.gc();
 } // mouseClicked
コード例 #24
0
ファイル: LinkTool.java プロジェクト: WU-ARL/RLI
 public void mouseDragged(MouseEvent e) {
   if (isEnabled()) {
     // System.out.println("LinkTool::mouseDragged");
     if (e.getSource() instanceof ONLGraphic)
       buttonAction.setIntermediate(e.getPoint(), (ONLGraphic) e.getSource());
   }
 }
コード例 #25
0
ファイル: ForwardAction.java プロジェクト: srnsw/xena
  /** Shows popup with forward history entries */
  private void showForwardHistory(MouseEvent e) {

    JPopupMenu forwardMenu = new JPopupMenu("Forward History");

    if (historyModel == null) {
      return;
    }

    Locale locale = ((JHelp) getControl()).getModel().getHelpSet().getLocale();
    Enumeration items = historyModel.getForwardHistory().elements();
    JMenuItem mi = null;
    int index = historyModel.getIndex() + 1;
    // while(items.hasMoreElements()){
    for (int i = 0; items.hasMoreElements(); i++) {
      HelpModelEvent item = (HelpModelEvent) items.nextElement();
      if (item != null) {
        String title = item.getHistoryName();
        if (title == null) {
          title = HelpUtilities.getString(locale, "history.unknownTitle");
        }
        mi = new JMenuItem(title);
        // mi.setToolTipText(item.getURL().getPath());
        mi.addActionListener(new HistoryActionListener(i + index));
        forwardMenu.add(mi);
      }
    }
    // if(e.isPopupTrigger())
    forwardMenu.show(e.getComponent(), e.getX(), e.getY());
  }
コード例 #26
0
ファイル: TextPanel.java プロジェクト: dimitarp/basex
  @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);
    }
  }
コード例 #27
0
    public void mouseMoved(MouseEvent ev) {
      JRootPane root = getRootPane();

      if (root.getWindowDecorationStyle() == JRootPane.NONE) {
        return;
      }

      Window w = (Window) ev.getSource();

      Frame f = null;
      Dialog d = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else if (w instanceof Dialog) {
        d = (Dialog) w;
      }

      // Update the cursor
      int cursor = getCursor(calculateCorner(w, ev.getX(), ev.getY()));

      if (cursor != 0
          && ((f != null && (f.isResizable() && (f.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0))
              || (d != null && d.isResizable()))) {
        w.setCursor(Cursor.getPredefinedCursor(cursor));
      } else {
        w.setCursor(lastCursor);
      }
    }
コード例 #28
0
    public void mousePressed(MouseEvent e) {
      if (e.getButton() == e.BUTTON3) {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(2);
        int index = list.locationToIndex(e.getPoint());
        GetImageFile gif = new GetImageFile(files[index]);

        JTextArea area =
            new JTextArea(
                "File: "
                    + gif.getImageString()
                    + "\n"
                    + "Score: "
                    + nf.format(scores[index])
                    + "\n"
                    + "Pairs: "
                    + nrpairs[index]);
        area.setEditable(false);
        area.setBorder(BorderFactory.createLineBorder(Color.black));
        area.setFont(new Font("times", Font.PLAIN, 12));
        PopupFactory factory = PopupFactory.getSharedInstance();
        popup =
            factory.getPopup(
                null,
                area,
                (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25,
                (int) e.getComponent().getLocationOnScreen().getY() + e.getY());
        popup.show();
      }
    }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   PickerTableModel model = getDataModel();
   ICFInternetISOCountryObj o =
       (ICFInternetISOCountryObj) model.getValueAt(row, COLID_ROW_HEADER);
   invokeWhenChosen.choseISOCountry(o);
   try {
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof JInternalFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       ((JInternalFrame) cont).setClosed(true);
     }
   } catch (Exception x) {
   }
 }
コード例 #30
0
ファイル: ArenaFrame.java プロジェクト: supercube/oop_final
 /* mouse events */
 public void mousePressed(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   /* left click */
   if (e.getButton() == MouseEvent.BUTTON1) {
     if (x >= posX && x < posX + Constant.BATTLEFIELD_WIDTH) {
       if (y >= posY) {
         if (y < posY + Constant.BATTLEFIELD_HEIGHT) {
           battle_field.doPress((x - posX), (y - posY));
           return;
         } else if (y < posY + Constant.BATTLEFIELD_HEIGHT + Constant.CARDPANEL_HEIGHT) {
           card_panel.doDrag(x - posX, y - (posY + Constant.BATTLEFIELD_HEIGHT));
           return;
         }
       }
     }
     /* right click */
   } else if (e.getButton() == MouseEvent.BUTTON3) {
     if (x >= posX && x < posX + Constant.BATTLEFIELD_WIDTH) {
       if (y >= posY) {
         if (y < posY + Constant.BATTLEFIELD_HEIGHT) {
           Skill skill = arena.player.useSkill(skill_id, x - posX, y - posY);
           if (skill != null) {
             arena.addSkill(skill);
           }
           return;
         } else if (y < posY + Constant.BATTLEFIELD_HEIGHT + Constant.CARDPANEL_HEIGHT) {
           card_panel.changeDetail(x - posX, y - (posY + Constant.BATTLEFIELD_HEIGHT));
           return;
         }
       }
     }
   }
 }