Exemplo n.º 1
0
  @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);
    }
  }
    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());
      }
    }
Exemplo n.º 3
0
  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);
      }
    }
  }
Exemplo n.º 4
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;
          }
        }
      }
    }
Exemplo n.º 5
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);
      }
    }
Exemplo n.º 6
0
 void profileList_mouseClicked(MouseEvent e) {
   JList theList = (JList) e.getSource();
   ListModel aModel = theList.getModel();
   int index = theList.locationToIndex(e.getPoint());
   if (index < 0) return;
   UniProfile aProfile = (UniProfile) aModel.getElementAt(index);
   nameTextField.setText(aProfile.toString());
 }
Exemplo n.º 7
0
 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);
   }
 }
Exemplo n.º 8
0
  @Override
  public final void mouseDragged(final MouseEvent e) {
    if (!SwingUtilities.isLeftMouseButton(e)) return;

    // selection mode
    rend.select(scroll.pos(), e.getPoint(), true);
    final int y = Math.max(20, Math.min(e.getY(), getHeight() - 20));
    if (y != e.getY()) scroll.pos(scroll.pos() + e.getY() - y);
  }
  private void updateRolloverColumn(MouseEvent e) {
    if (header.getDraggedColumn() == null && header.contains(e.getPoint())) {

      int col = header.columnAtPoint(e.getPoint());
      if (col != rolloverColumn) {
        rolloverColumn = col;
        header.repaint();
      }
    }
  }
  /**
   * Method to display pixel information based on a mouse event
   *
   * @param e a mouse event
   */
  private void displayPixelInformation(MouseEvent e) {

    // get the cursor x and y
    int cursorX = e.getX();
    int cursorY = e.getY();

    // get the x and y in the original (not scaled image)
    int pictureX = (int) (cursorX / zoomFactor + numberBase);
    int pictureY = (int) (cursorY / zoomFactor + numberBase);

    // display the information for this x and y
    displayPixelInformation(pictureX, pictureY);
  }
Exemplo n.º 11
0
 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();
 }
Exemplo n.º 12
0
 @Override
 public void mouseMoved(MouseEvent e) {
   Point pt = e.getPoint();
   int prevRow = row;
   int prevCol = col;
   row = table.rowAtPoint(pt);
   col = table.columnAtPoint(pt);
   if (row < 0 || col < 0) {
     row = -1;
     col = -1;
   }
   // >>>> HyperlinkCellRenderer.java
   // @see
   // http://java.net/projects/swingset3/sources/svn/content/trunk/SwingSet3/src/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java
   if (row == prevRow && col == prevCol) {
     return;
   }
   Rectangle repaintRect;
   if (row >= 0 && col >= 0) {
     Rectangle r = table.getCellRect(row, col, false);
     if (prevRow >= 0 && prevCol >= 0) {
       repaintRect = r.union(table.getCellRect(prevRow, prevCol, false));
     } else {
       repaintRect = r;
     }
   } else {
     repaintRect = table.getCellRect(prevRow, prevCol, false);
   }
   table.repaint(repaintRect);
   // <<<<
   // table.repaint();
 }
Exemplo n.º 13
0
 void jListOnlineUsers_mouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2) {
     jTextFieldTargetUser.setText(((HostItem) jListOnlineUsers.getSelectedValue()).name);
     Flasher.instance().flashBackground(jTextFieldTargetUser, Color.yellow, 2);
     jTextFieldSendMessages.requestFocus();
   }
 }
 public void processMouseEvent(
     JMenuItem item, MouseEvent e, MenuElement path[], MenuSelectionManager manager) {
   Point p = e.getPoint();
   if (p.x >= 0 && p.x < item.getWidth() && p.y >= 0 && p.y < item.getHeight()) {
     if (e.getID() == MouseEvent.MOUSE_RELEASED) {
       manager.clearSelectedPath();
       item.doClick(0);
       item.setArmed(false);
     } else manager.setSelectedPath(path);
   } else if (item.getModel().isArmed()) {
     MenuElement newPath[] = new MenuElement[path.length - 1];
     int i, c;
     for (i = 0, c = path.length - 1; i < c; i++) newPath[i] = path[i];
     manager.setSelectedPath(newPath);
   }
 }
 public void mousePressed(MouseEvent e) {
   if (e.isConsumed()) {
     selectedOnPress = false;
     return;
   }
   selectedOnPress = true;
   adjustFocusAndSelection(e);
 }
Exemplo n.º 16
0
    public void mouseClicked(MouseEvent e) {
      if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 1) {
        JButton source = (JButton) e.getSource();

        String value = source.getText();
        int day = Integer.parseInt(value);
        calendar.set(Calendar.DAY_OF_MONTH, day);
        Date selectDate = this.getSelectDate();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        MyDateChooseBtn.this.setText(simpleDateFormat.format(selectDate));
        Jtext.setText(simpleDateFormat.format(selectDate));

        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH) + 1;
        //        System.out.println(year + "骞�" + month + "鏈�" + day + "鏃�");
        f.dispose();
      }
    }
Exemplo n.º 17
0
 public void mouseClicked(MouseEvent e) {
   if (e.getSource() == bottomText) {
     try {
       getAppletContext().showDocument(new URL(linkURL), "_blank");
     } catch (java.net.MalformedURLException ex) {
     }
   } else {
     maybeShowPopup(e);
   }
 }
Exemplo n.º 18
0
    public void mousePressed(MouseEvent ev) {
      JRootPane rootPane = getRootPane();

      if (rootPane.getWindowDecorationStyle() == JRootPane.NONE) {
        return;
      }
      Point dragWindowOffset = ev.getPoint();
      Window w = (Window) ev.getSource();
      if (w != null) {
        w.toFront();
      }
      Point convertedDragWindowOffset =
          SwingUtilities.convertPoint(w, dragWindowOffset, getTitlePane());

      Frame f = null;
      Dialog d = null;

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

      int frameState = (f != null) ? f.getExtendedState() : 0;

      if (getTitlePane() != null && getTitlePane().contains(convertedDragWindowOffset)) {
        if ((f != null && ((frameState & Frame.MAXIMIZED_BOTH) == 0) || (d != null))
            && dragWindowOffset.y >= BORDER_DRAG_THICKNESS
            && dragWindowOffset.x >= BORDER_DRAG_THICKNESS
            && dragWindowOffset.x < w.getWidth() - BORDER_DRAG_THICKNESS) {
          isMovingWindow = true;
          dragOffsetX = dragWindowOffset.x;
          dragOffsetY = dragWindowOffset.y;
        }
      } else if (f != null && f.isResizable() && ((frameState & Frame.MAXIMIZED_BOTH) == 0)
          || (d != null && d.isResizable())) {
        dragOffsetX = dragWindowOffset.x;
        dragOffsetY = dragWindowOffset.y;
        dragWidth = w.getWidth();
        dragHeight = w.getHeight();
        dragCursor = getCursor(calculateCorner(w, dragWindowOffset.x, dragWindowOffset.y));
      }
    }
Exemplo n.º 19
0
 public void mouseExited(MouseEvent e) {
   JButton jbutton = (JButton) e.getSource();
   int comm = Integer.parseInt(jbutton.getActionCommand());
   int today = getNowCalendar().get(Calendar.DAY_OF_MONTH);
   if (comm == today) {
     jbutton.setBackground(todayBtnColor);
   } else {
     jbutton.setBackground(palletTableColor);
   }
 }
 @Override
 public String getToolTipText(MouseEvent evt) {
   int index = locationToIndex(evt.getPoint());
   if (index == -1) {
     return "";
   } else {
     ListItem<T> item = (ListItem<T>) model.getElementAt(index);
     return item.dataItem.toString();
   }
 }
 void forwardEventToParent(MouseEvent e) {
   getParent()
       .dispatchEvent(
           new MouseEvent(
               getParent(),
               e.getID(),
               e.getWhen(),
               e.getModifiers(),
               e.getX(),
               e.getY(),
               e.getXOnScreen(),
               e.getYOnScreen(),
               e.getClickCount(),
               e.isPopupTrigger(),
               MouseEvent.NOBUTTON));
 }
    private void setDispatchComponent(MouseEvent e) {
      // Get location
      Point spreadPoint = e.getPoint();
      int row = grid.rowAtPoint(spreadPoint);
      int column = grid.columnAtPoint(spreadPoint);

      // Get editor component
      Component editorComponent = grid.getEditorComponent();

      // Get dispatchComponent
      Point editorPoint = SwingUtilities.convertPoint(grid, spreadPoint, editorComponent);
      dispatchComponent =
          SwingUtilities.getDeepestComponentAt(editorComponent, editorPoint.x, editorPoint.y);
    }
Exemplo n.º 23
0
 public void mouseDragged(MouseEvent e) {
   int m = e.getModifiers();
   int type = DnDEvent.DND_ONE;
   if (e.isControlDown()) type = DnDEvent.DND_LINE;
   else if (((m & InputEvent.BUTTON2_MASK) != 0) || ((m & InputEvent.BUTTON3_MASK) != 0))
     type = DnDEvent.DND_END;
   if (startPoint == null) startPoint = new Point(e.getX(), e.getY());
   fireDragToolbar(e.getX() - startPoint.x, (e.getY() - startPoint.y), type);
   dragging = true;
 }
 private void dateTableMouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2) {
     try {
       DomainEditor domainEditor =
           new DomainEditor(
               ArchDescriptionDates.class,
               editorField.getParentEditor(),
               "Dates",
               new ArchDescriptionDatesFields());
       domainEditor.setCallingTable(dateTable);
       domainEditor.setNavigationButtonListeners(domainEditor);
       editRelatedRecord(dateTable, ArchDescriptionDates.class, true, domainEditor);
     } catch (UnsupportedTableModelException e1) {
       new ErrorDialog("Error creating editor for Dates", e1).showDialog();
     }
   }
 }
 // {{{ getToolTipText()
 public String getToolTipText(MouseEvent event) {
   Point p = event.getPoint();
   switch (this.columnAtPoint(p)) {
     case 0:
       return "Start column for the sort field";
     case 1:
       return "End column for the sort field";
     case 2:
       return "Enable for descending sort order";
     case 3:
       return "Enable for case insensitive sort";
     case 4:
       return "Enable for numeric type sort";
     case 5:
       return "Trim whitespace before sorting";
   }
   return null;
 } // }}}
  private void instancesTableMouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2) {
      // get the current instance record to edit
      DomainObject instanceRecord = null;
      int selectedRow = getInstancesTable().getSelectedRow();
      if (selectedRow != -1) {
        instanceRecord = getInstancesTable().getSortedList().get(selectedRow);
      }

      if (usePluginDomainEditor(false, instanceRecord, getInstancesTable())) {
        return;
      }

      if (handleTableMouseClick(e, getInstancesTable(), ArchDescriptionInstances.class)
          == JOptionPane.OK_OPTION) {
        findLocationForInstance(currentInstance);
      }
    }
  }
    public void mouseDragged(MouseEvent e) {
      if (shouldIgnore(e)) {
        return;
      }

      repostEvent(e);

      CellEditor editor = grid.getCurrentCellEditor();
      if (editor == null || editor.shouldSelectCell(e)) {
        Point p = e.getPoint();
        int row = grid.rowAtPoint(p);
        int column = grid.columnAtPoint(p);
        // The autoscroller can generate drag events outside the Table's range.
        if ((column == -1) || (row == -1)) {
          return;
        }
        grid.changeSelection(row, column, false, true);
      }
    }
Exemplo n.º 28
0
  public void mouseClicked(MouseEvent e) {
    /*can = false;
    boolean f = true;
    for (int i = 0; i < 8; i++)
    {
    	for (int j = 0; j < 8; j++)
    	if (cell[i][j] == e.getSource())
    	{
    		int judege = Clicked(cell[i][j]);
    		f = false;
    		break;
    	}
    	if (!f) break;
    }*/

    boolean flage = CheckAll();
    if (flage) {
      can = false;
      if (kind.equals("" + turn)) {
        ChessBoard cel = (ChessBoard) (e.getSource());
        int judge = Clicked(cel);
        if (judge == 1) {
          try {
            System.out.println("发送前:" + cell[3][5].taken);
            out66.writeObject("落子" + turn);
            out66.flush();
            out66.writeObject(stateList.get(stateList.size() - 1));
            out66.flush();
            out66.writeObject(takenList.get(takenList.size() - 1));
            out66.flush();
          } catch (IOException e1) {
            e1.printStackTrace();
          }
        }
      } else {
        JOptionPane.showMessageDialog(null, "请确定您的身份,您此时不能落子");
      }
    } else CheckAtTheEnd();
  }
Exemplo n.º 29
0
 public void mouseExited(MouseEvent ev) {
   Window w = (Window) ev.getSource();
   w.setCursor(lastCursor);
 }
Exemplo n.º 30
0
 public void mouseEntered(MouseEvent ev) {
   Window w = (Window) ev.getSource();
   lastCursor = w.getCursor();
   mouseMoved(ev);
 }