예제 #1
0
  void moveNearMuffin() {
    if (getTitle().equals(Strings.getString("muffin.title"))) {
      return;
    }

    Dimension screenSize = getToolkit().getScreenSize();
    MuffinFrame muffin = getFrame(Strings.getString("muffin.title"));
    Dimension muffinSize = muffin.getSize();
    Point muffinLocation = muffin.getLocationOnScreen();
    Dimension size = getSize();
    int x = 0, y = 0;

    x = muffinLocation.x + muffinSize.width;
    y = muffinLocation.y;

    if (x + size.width > screenSize.width) {
      x = muffinLocation.x - size.width;
      if (x < 0) x = 0;
    }
    if (y + size.height > screenSize.height) {
      y -= (y + size.height) - screenSize.height;
      if (y < 0) y = 0;
    }

    setLocation(x, y);
  }
예제 #2
0
 static MuffinFrame getFrame(String title) {
   for (int i = 0; i < frames.size(); i++) {
     MuffinFrame frame = (MuffinFrame) frames.elementAt(i);
     if (frame.getTitle().equals(title)) {
       return frame;
     }
   }
   return null;
 }