コード例 #1
0
 private void setMiddle() {
   Point point = owner.getLocationOnScreen();
   int x = point.x;
   int y = point.y;
   int width = (int) ((owner.getWidth() - this.getWidth()) / 2);
   int height = (int) ((owner.getHeight() - this.getHeight()) / 2);
   this.setLocation(x + width, y + height);
 }
コード例 #2
0
 private static GraphicsDevice getScreen(JFrame window) {
   for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
     if (gd.getDefaultConfiguration().getBounds().contains(window.getLocationOnScreen()))
       return gd;
   }
   System.err.println(
       window + " does not appear to be on any screen; fullscreening onto default screen");
   return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
 }