Ejemplo n.º 1
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;
          }
        }
      }
    }
Ejemplo n.º 2
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);
      }
    }
Ejemplo n.º 3
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());
 }
Ejemplo n.º 4
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);
   }
 }
Ejemplo n.º 5
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);
   }
 }
Ejemplo n.º 6
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();
      }
    }
Ejemplo n.º 7
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));
      }
    }
Ejemplo n.º 8
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();
  }
Ejemplo n.º 9
0
 public void mouseExited(MouseEvent ev) {
   Window w = (Window) ev.getSource();
   w.setCursor(lastCursor);
 }
Ejemplo n.º 10
0
 public void mouseEntered(MouseEvent ev) {
   Window w = (Window) ev.getSource();
   lastCursor = w.getCursor();
   mouseMoved(ev);
 }
Ejemplo n.º 11
0
    public void mouseDragged(MouseEvent ev) {
      Window w = (Window) ev.getSource();
      Point pt = ev.getPoint();

      if (isMovingWindow) {
        Point windowPt;
        try {
          windowPt = (Point) AccessController.doPrivileged(getLocationAction);
          windowPt.x = windowPt.x - dragOffsetX;
          windowPt.y = windowPt.y - dragOffsetY;
          w.setLocation(windowPt);
        } catch (PrivilegedActionException e) {
        }
      } else if (dragCursor != 0) {
        Rectangle r = w.getBounds();
        Rectangle startBounds = new Rectangle(r);
        Dimension min = w.getMinimumSize();

        switch (dragCursor) {
          case Cursor.E_RESIZE_CURSOR:
            adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, 0);
            break;
          case Cursor.S_RESIZE_CURSOR:
            adjust(r, min, 0, 0, 0, pt.y + (dragHeight - dragOffsetY) - r.height);
            break;
          case Cursor.N_RESIZE_CURSOR:
            adjust(r, min, 0, pt.y - dragOffsetY, 0, -(pt.y - dragOffsetY));
            break;
          case Cursor.W_RESIZE_CURSOR:
            adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), 0);
            break;
          case Cursor.NE_RESIZE_CURSOR:
            adjust(
                r,
                min,
                0,
                pt.y - dragOffsetY,
                pt.x + (dragWidth - dragOffsetX) - r.width,
                -(pt.y - dragOffsetY));
            break;
          case Cursor.SE_RESIZE_CURSOR:
            adjust(
                r,
                min,
                0,
                0,
                pt.x + (dragWidth - dragOffsetX) - r.width,
                pt.y + (dragHeight - dragOffsetY) - r.height);
            break;
          case Cursor.NW_RESIZE_CURSOR:
            adjust(
                r,
                min,
                pt.x - dragOffsetX,
                pt.y - dragOffsetY,
                -(pt.x - dragOffsetX),
                -(pt.y - dragOffsetY));
            break;
          case Cursor.SW_RESIZE_CURSOR:
            adjust(
                r,
                min,
                pt.x - dragOffsetX,
                0,
                -(pt.x - dragOffsetX),
                pt.y + (dragHeight - dragOffsetY) - r.height);
            break;
          default:
            break;
        }
        if (!r.equals(startBounds)) {
          w.setBounds(r);
          // Defer repaint/validate on mouseReleased unless dynamic
          // layout is active.
          if (Toolkit.getDefaultToolkit().isDynamicLayoutActive()) {
            w.validate();
            getRootPane().repaint();
          }
        }
      }
    }
Ejemplo n.º 12
0
 public void mouseEntered(MouseEvent e) {
   JButton jbutton = (JButton) e.getSource();
   jbutton.setBackground(moveButtonColor);
 }
Ejemplo n.º 13
0
 public void mouseExited(MouseEvent e) {
   if (e.getSource() == bottomText) {
     bottomText.setCursor(Cursor.getDefaultCursor());
   }
 }
Ejemplo n.º 14
0
 public void mouseEntered(MouseEvent e) {
   if (e.getSource() == bottomText) {
     bottomText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
   }
 }