Пример #1
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();
 }
Пример #2
0
 public void mousePressed(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   for (int i = 0; mRect != null && i < mRect.length; i++) {
     if (mRect[i].contains(x, y)) {
       mPressedButton = i;
       mMouseOverButton = true;
       repaint();
     }
   }
 }