用Applet写的菜单程序 machine(6) } else { y = Math.max(0, Math.min(size().height-maxHeight-1, dstPt[curMenu].y - maxHeight)); } x = dstPt[curMenu].x + srcRect[curMenu].width-maxWidth-1; for (int i=0; i menuItemRect[i].x = x; menuItemRect[i].y = y; menuItemRect[i].width = maxWidth; y += menuItemRect[i].height; } getAppletContext().showStatus(url[curMenu]); } } repaint(); } return true; }
// Returns the index of the rectangle in rs containing x and y. // Returns -1 if either rs is null or x and y is not in rs. int inMenu(Rectangle[] rs, int x, int y) { if (rs != null) { for (int i=0; i if (rs[i].inside(x, y)) { return i; } } } return -1; } }