Esempio n. 1
0
 /* 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;
         }
       }
     }
   }
 }
 // Handle mouse actions
 public void mousePressed(MouseEvent mouseEvent) {
   if (this.isArmed() && this.isUseRubberBand() && mouseEvent.getButton() == MouseEvent.BUTTON1) {
     if ((mouseEvent.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
       if (!mouseEvent.isControlDown()) {
         this.setActive(true);
         measureTool.addControlPoint();
         if (measureTool.getControlPoints().size() == 1) {
           measureTool.addControlPoint(); // Simulate a second click
         }
         // Set the rubber band target to the last control point or the relevant control for
         // regular shapes.
         if (measureTool.isRegularShape()) {
           String initControl =
               measureTool.getShapeInitialControl(measureTool.getWwd().getCurrentPosition());
           rubberBandTarget = measureTool.getControlPoint(initControl);
         } else {
           rubberBandTarget =
               (MeasureTool.ControlPoint)
                   measureTool.getControlPoints().get(measureTool.getControlPoints().size() - 1);
         }
         measureTool.firePropertyChange(MeasureTool.EVENT_RUBBERBAND_START, null, null);
       }
     }
     mouseEvent.consume();
   } else if (!this.isArmed()
       && mouseEvent.getButton() == MouseEvent.BUTTON1
       && mouseEvent.isAltDown()) {
     if (!this.measureTool.isRegularShape()) {
       this.setMoving(true);
       this.movingTarget = this.lastPickedObject;
     }
     mouseEvent.consume();
   }
 }
  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);
      }
    }
  }
  /**
   * Converts the specified mouse event's screen point from WebView coordinates to Windows
   * coordinates, and returns a new event who's screen point is in Windows coordinates, with the
   * origin at the upper left corner of the WebView window.
   *
   * @param e The event to convert.
   * @return A new mouse event in the Windows coordinate system.
   */
  protected MouseEvent convertToWindows(MouseEvent e) {
    int x = e.getX();
    int y = e.getY();

    // Translate OpenGL screen coordinates to Windows by moving the Y origin from the lower left
    // corner to
    // the upper left corner and flipping the direction of the Y axis.
    y = this.frameSize.height - y;

    if (e instanceof MouseWheelEvent) {
      return new MouseWheelEvent(
          (Component) e.getSource(),
          e.getID(),
          e.getWhen(),
          e.getModifiers(),
          x,
          y,
          e.getClickCount(),
          e.isPopupTrigger(),
          ((MouseWheelEvent) e).getScrollType(),
          ((MouseWheelEvent) e).getScrollAmount(),
          ((MouseWheelEvent) e).getWheelRotation());
    } else {
      return new MouseEvent(
          (Component) e.getSource(),
          e.getID(),
          e.getWhen(),
          e.getModifiers(),
          x,
          y,
          e.getClickCount(),
          e.isPopupTrigger(),
          e.getButton());
    }
  }
 @Override
 public void mousePressed(MouseEvent me) {
   x = me.getX();
   y = me.getY();
   altDown = me.isAltDown() || me.isAltGraphDown();
   undo = (me.getButton() == MouseEvent.BUTTON3) || altDown;
   ctrlDown = me.isControlDown() || me.isMetaDown();
   shiftDown = me.isShiftDown();
   first = true;
   if (!oneShot) {
     if (timer == null) {
       timer =
           new Timer(
               delay,
               e -> {
                 Point worldCoords = view.viewToWorld((int) x, (int) y);
                 tick(worldCoords.x, worldCoords.y, undo, first, 1.0f);
                 view.updateStatusBar(worldCoords.x, worldCoords.y);
                 first = false;
               });
       timer.setInitialDelay(0);
       timer.start();
       //                start = System.currentTimeMillis();
     }
   } else {
     Point worldCoords = view.viewToWorld((int) x, (int) y);
     tick(worldCoords.x, worldCoords.y, undo, true, 1.0f);
     view.updateStatusBar(worldCoords.x, worldCoords.y);
     Dimension dimension = getDimension();
     if (dimension != null) {
       dimension.armSavePoint();
     }
     logOperation(undo ? statisticsKeyUndo : statisticsKey);
   }
 }
 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) {
   }
 }
 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);
 }
Esempio n. 8
0
    @Override
    public void mousePressed(MouseEvent me) {
      //      // check if this happened in the gutter area
      //      if (me.getX() < Editor.LEFT_GUTTER) {
      //        if (me.getButton() == MouseEvent.BUTTON1) { // && me.getClickCount() == 2) {
      //          //int line = me.getY() / painter.getFontMetrics().getHeight() + firstLine;
      //          int offset = xyToOffset(me.getX(), me.getY());
      //          if (offset >= 0) {
      //            int lineIndex = getLineOfOffset(offset);
      //            editor.toggleBreakpoint(lineIndex);
      //          }
      ////          if (line >= 0 && line < getLineCount()) {
      ////            //editor.gutterDblClicked(line);
      ////            editor.toggleBreakpoint(line);
      ////          }
      //        }
      //        return;
      //      }

      if (me.getButton() == MouseEvent.BUTTON3) {
        if (!editor.hasJavaTabs()) { // tooltips, etc disabled for java tabs
          fetchPhrase(me);
        }
      }

      // forward to standard listeners
      for (MouseListener ml : mouseListeners) {
        ml.mousePressed(me);
      }
    }
 public static void checkClickedModifiersTest(int testModifier, MouseEvent event) {
   int[] curStandardModifiers = getStandardArray(testModifier);
   int[] curStandardExModifiers = getStandardExArray(testModifier);
   //        int index = (button - 4)*3 + 2;
   int button = event.getButton();
   int modifiers = event.getModifiers();
   int modifiersEx = event.getModifiersEx();
   int index = (button - 1) * 3 + 2;
   dumpValues(
       button, modifiers, curStandardModifiers[index], modifiersEx, curStandardExModifiers[index]);
   if (modifiers != curStandardModifiers[index]) {
     if (debug) {
       System.out.println("Test failed :  Clicked. modifiers != modifiersStandard");
     } else {
       throw new RuntimeException("Test failed :  Clicked. modifiers != modifiersStandard");
     }
   }
   if (modifiersEx != curStandardExModifiers[index]) {
     if (debug) {
       System.out.println("Test failed :  Clicked. modifiersEx != curStandardExModifiers");
     } else {
       throw new RuntimeException("Test failed :  Clicked. modifiersEx != curStandardExModifiers");
     }
   }
   HashMap<String, String> paramStringElements = tokenizeParamString(event.paramString());
   checkButton(paramStringElements, button);
   checkModifiers(testModifier, paramStringElements, button);
   checkExtModifiersOnReleaseClick(testModifier, paramStringElements, button);
 }
 public void mouseReleased(MouseEvent mouseEvent) {
   if (this.isArmed() && this.isUseRubberBand() && mouseEvent.getButton() == MouseEvent.BUTTON1) {
     if (this.isUseRubberBand() && measureTool.getPositions().size() == 1)
       measureTool.removeControlPoint();
     this.setActive(false);
     rubberBandTarget = null;
     // Disarm after second control point of a line or regular shape
     autoDisarm();
     mouseEvent.consume();
     measureTool.firePropertyChange(MeasureTool.EVENT_RUBBERBAND_STOP, null, null);
   } else if (this.isMoving() && mouseEvent.getButton() == MouseEvent.BUTTON1) {
     this.setMoving(false);
     this.movingTarget = null;
     mouseEvent.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();
   }
 }
Esempio n. 12
0
  protected void processMouseEvent(final MouseEvent e) {
    if (e.isPopupTrigger() && e.getComponent().isShowing()) {
      super.processMouseEvent(e);
      return;
    }

    if (UIUtil.isCloseClick(e)) {
      myDecorator.fireHiddenSide();
      return;
    }

    if (e.getButton() == MouseEvent.BUTTON1) {
      if (MouseEvent.MOUSE_PRESSED == e.getID()) {
        myPressedPoint = e.getPoint();
        myPressedWhenSelected = isSelected();
        myDragCancelled = false;
      } else if (MouseEvent.MOUSE_RELEASED == e.getID()) {
        finishDragging();
        myPressedPoint = null;
        myDragButtonImage = null;
      }
    }

    super.processMouseEvent(e);
  }
Esempio n. 13
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();
      }
    }
Esempio n. 14
0
  public void mouseClicked(MouseEvent e) {
    // loop through game buttons to see if one has been clicked
    for (int i = 0; i < row; i++) {
      for (int j = 0; j < col; j++) {
        if (e.getSource() == gbuttons[i][j]) {
          // see if that button has a flag or mine, and what mouse button clicked it
          if (e.getButton() == e.BUTTON1) {

            if (bombs[i][j] == true && flag[i][j] == false) {
              ImageIcon bomb = new ImageIcon("bomb.png");
              gbuttons[i][j].setIcon(bomb); // set label to bomb (* for now, picture later)
              clicked[i][j] = true;
              gameover();

            } else if (flag[i][j]
                == true) // checks to see if button that was clicked has a flag on it
            {

              gbuttons[i][j].setIcon(null);
              flag[i][j] = false;
              clicked[i][j] =
                  false; // it's important to change this, as it changes the button to act as if it
                         // was never clicked.
            } else {
              SurroundB(
                  i,
                  j); // if no bomb or flag on button pressed, the implement this method to
                      // determine how many bombs are around the button clicked
            }
          } else if (e.getButton() == e.BUTTON3) {
            if (flag[i][j] == false
                && clicked[i][j]
                    == false) // if no flag, and button has not been clicked (does not have a flag,
                              // is greyed out, and does not have a number)
            {
              ImageIcon flags = new ImageIcon("flags.png");
              gbuttons[i][j].setIcon(flags);
              flag[i][j] = true;
              clicked[i][j] = true;
            }
          }
        }
      }
    }
    win();
  }
 public void mouseClicked(MouseEvent e) {
   System.out.println("CLICKED " + e);
   if (e.getButton() > MouseEvent.BUTTON3) {
     System.out.println("Extra button affected. Skip.");
   } else {
     MouseModifiersUnitTest_Standard.checkClickedModifiersTest(
         modifier, e); // e.getButton(), e.getModifiers(), e.getModifiersEx()
   }
 }
Esempio n. 16
0
    public void mouseReleased(MouseEvent e) {
      int mods = e.getModifiersEx();

      if (nodrag && e.getButton() == MouseEvent.BUTTON3) {
        popupMenu.show(JImage.this, (int) e.getPoint().getX(), (int) e.getPoint().getY());
      }

      nodrag = true;
      dragBegin = null;
    }
Esempio n. 17
0
    public void mouseClicked(MouseEvent e) {
      if (e.getButton() == e.BUTTON1) {
        showButton.setEnabled(list.getSelectedIndex() != -1 ? true : false);

        if (e.getClickCount() == 2) {
          int index = list.locationToIndex(e.getPoint());
          sp.doVisualComparison(index, scores[index]);
        }
      }
    }
 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;
   }
   ListTableModel model = getDataModel();
   ICFInternetVersionObj o = (ICFInternetVersionObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = null;
   String classCode = o.getClassCode();
   if (classCode.equals("VERN")) {
     frame = swingSchema.getVersionFactory().newViewEditJInternalFrame(o);
     frame.addInternalFrameListener(getViewEditInternalFrameListener());
     ((ICFInternetSwingVersionJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   } else if (classCode.equals("MJVR")) {
     frame =
         swingSchema
             .getMajorVersionFactory()
             .newViewEditJInternalFrame((ICFInternetMajorVersionObj) o);
     frame.addInternalFrameListener(getViewEditInternalFrameListener());
     ((ICFInternetSwingMajorVersionJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   } else if (classCode.equals("MNVR")) {
     frame =
         swingSchema
             .getMinorVersionFactory()
             .newViewEditJInternalFrame((ICFInternetMinorVersionObj) o);
     frame.addInternalFrameListener(getViewEditInternalFrameListener());
     ((ICFInternetSwingMinorVersionJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   } else {
     frame = null;
   }
   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();
   }
 }
Esempio n. 19
0
 public void mouseReleased(MouseEvent e) {
   if (e.getButton() == e.BUTTON1 && connected) {
     if (dec == null) return;
     lc.increment();
     TextEvent cu = new CaretUpdate(area1.getCaretPosition(), lc.getTimeStamp());
     dec.sendObjectToAllPeers(cu);
     er.getEventHistoryLock().lock();
     er.getEventHistory().add(cu);
     er.getEventHistoryLock().unlock();
   }
 }
Esempio n. 20
0
  public void mouseReleased(MouseEvent mouseEvent) {
    if (MouseEvent.BUTTON1 != mouseEvent.getButton()) return;

    if (this.getShape().isResizeable()) this.setCursor(null);

    this.getShape().setResizeable(false);

    mouseEvent.consume(); // prevent view operations

    this.firePropertyChange(SECTOR_PROPERTY, this.previousSector, null);
  }
Esempio n. 21
0
 /**
  * Allow to close the editor with a middle click on his tab.
  *
  * @param e The event.
  */
 @Override
 public void mouseClicked(MouseEvent e) {
   if (e.getButton() == MouseEvent.BUTTON2 && countEditors() > 0) {
     Point clic = e.getPoint();
     int idx = indexAtLocation(clic.x, clic.y);
     if (idx != -1) {
       // Middle click on a tab was clicked: close it.
       AbstractEditorPanel editor = (AbstractEditorPanel) getComponentAt(idx);
       removeEditor(editor, true);
     }
   }
 }
Esempio n. 22
0
 public void mousePressed(MouseEvent e) {
   if (e.getButton() == 3 && !(currentTool instanceof CursorTool)) {
     setTool(cursorTool, cursorButton);
   } else {
     Point p = new Point(e.getX(), e.getY());
     WorkingView.this.getTool().mouseDown(p.x, p.y, e);
   }
   if (currentTool instanceof ArrowTool || currentTool instanceof TextBoxTool) {
     setTool(cursorTool, cursorButton);
   }
   board.requestFocus();
 }
Esempio n. 23
0
    public void mousePressed(MouseEvent e) {
      if (e == null || e.isConsumed()) {
        return;
      }

      if (!this.isEnabled()) {
        return;
      }

      if (e.getButton() == MouseEvent.BUTTON1) {
        this.handleSelect();
      }
    }
  // Handle single click for removing control points
  public void mouseClicked(MouseEvent mouseEvent) {
    if (measureTool == null) return;

    if (this.isArmed() && mouseEvent.getButton() == MouseEvent.BUTTON1) {
      if (mouseEvent.isControlDown()) measureTool.removeControlPoint();
      else if (!this.isUseRubberBand()) {
        measureTool.addControlPoint();
        // Disarm after second control point of a line or regular shape
        autoDisarm();
      }
      mouseEvent.consume();
    }
  }
Esempio n. 25
0
    public void mousePressed(MouseEvent event) {

      // Point selectedPoint = event.getPoint();
      int xPos = event.getX() - 20;
      int yPos = event.getY() - 50;
      int col = (int) (xPos / 50);
      int row = (int) (yPos / 50);
      // If left mouse is clicked, reveal
      // Get the coordinates of the click and use cascade on square

      if (event.getButton() == MouseEvent.BUTTON1) {

        if (xPos > 0 && xPos < 800 && yPos > 0 && yPos < 800) {

          if (!board[row][col].isReveal() && !board[row][col].isFlag()) cascade(board[row][col]);
        }
      }
      // If right mouse button is clicked, place flag
      else if (event.getButton() == MouseEvent.BUTTON3) {
        if (xPos > 0 && xPos < 800 && yPos > 0 && yPos < 800) {

          if (!board[row][col].isFlag && !board[row][col].isReveal() && currentFlags < maxFlags) {
            board[row][col].addFlag();
            currentFlags++;
            if (board[row][col].isBear()) {
              bearsCovered++;
              checkWin();
            }
          } else if (board[row][col].isFlag) {
            board[row][col].removeFlag();
            currentFlags--;
            if (board[row][col].isBear()) {
              bearsCovered--;
            }
          }
        }
      }
      repaint();
    }
Esempio n. 26
0
  public void mouseClicked(MouseEvent e) {
    if (this.isArmed()) {
      if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
        Object topObject = null;
        PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition();
        if (pickedObjects != null) topObject = pickedObjects.getTopObject();

        if (topObject instanceof ControlPointMarker) {
          this.removeVertex((ControlPointMarker) topObject);
          e.consume();
        } else {
          this.addVertex(e.getPoint());
          e.consume();
        }
      }
    }
  }
Esempio n. 27
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();
      }
    }
Esempio n. 28
0
  /**
   * Propagates certain mouse events, such as MOUSE_CLICKED, MOUSE_RELEASED etc. to the deepest
   * component.
   *
   * @param e The MouseEvent to be propagated.
   */
  protected void propagateMouseListenerEvent(MouseEvent e) {
    if (POPUP_IS_MODAL == false) {

      Component deepestComponent = getDeepestComponent(e.getPoint());

      if (deepestComponent != null) {
        MouseListener[] mouseListeners = deepestComponent.getMouseListeners();

        int eventID;

        // Get the event type
        eventID = e.getID();

        Point pt = e.getPoint();

        Point convertedPt = SwingUtilities.convertPoint(glassPane, e.getPoint(), deepestComponent);

        MouseEvent evt =
            new MouseEvent(
                deepestComponent,
                e.getID(),
                System.currentTimeMillis(),
                e.getModifiers(),
                convertedPt.x,
                convertedPt.y,
                e.getClickCount(),
                e.isPopupTrigger(),
                e.getButton());

        // Distibute the event to the component's listeners.
        for (int i = 0; i < mouseListeners.length; i++) {

          // Forward the appropriate mouse event
          if (eventID == MouseEvent.MOUSE_PRESSED) {
            mouseListeners[i].mousePressed(evt);
          } else if (eventID == MouseEvent.MOUSE_RELEASED) {
            mouseListeners[i].mouseReleased(evt);
          } else if (eventID == MouseEvent.MOUSE_CLICKED) {
            mouseListeners[i].mouseClicked(evt);
          }
        }
      }
    }
  }
 private void dispatchEvent(MouseEvent me) {
   if (rect != null && rect.contains(me.getX(), me.getY())) {
     Point pt = me.getPoint();
     pt.translate(-offset, 0);
     comp.setBounds(rect);
     comp.dispatchEvent(
         new MouseEvent(
             comp,
             me.getID(),
             me.getWhen(),
             me.getModifiers(),
             pt.x,
             pt.y,
             me.getClickCount(),
             me.isPopupTrigger(),
             me.getButton()));
     if (!comp.isValid()) container.repaint();
   }
 }
Esempio n. 30
0
  public static void click(MouseEvent e) {
    if (e.getButton() == 1) {
      if (isOpen) {
        for (int i = 0; i < invBar.length; i++) {
          if (invBar[i].contains(Component.mse)) {
            if (invBar[i].id != Tile.air && !isHolding) {
              holdingID = invBar[i].id;
              invBar[i].id = Tile.air;

              isHolding = true;
            } else if ((isHolding) && (invBar[i].id == Tile.air)) {
              invBar[i].id = holdingID;
              isHolding = false;
            } else if ((isHolding) && (invBar[i].id != Tile.air)) {
              int[] temp_cell = invBar[i].id;
              invBar[i].id = holdingID;
              holdingID = temp_cell;
            }
          }
        }

        for (int i = 0; i < invBag.length; i++) {
          if (invBag[i].contains(Component.mse)) {
            if (invBag[i].id != Tile.air && !isHolding) {
              holdingID = invBag[i].id;
              invBag[i].id = Tile.air;

              isHolding = true;
            } else if ((isHolding) && (invBag[i].id == Tile.air)) {
              invBag[i].id = holdingID;
              isHolding = false;
            } else if ((isHolding) && (invBag[i].id != Tile.air)) {
              int[] temp_cell = invBag[i].id;
              invBag[i].id = holdingID;
              holdingID = temp_cell;
            }
          }
        }
      }
    }
  }