Here you can find the source of fits(Rectangle r)
Parameter | Description |
---|---|
r | - desired rectangle |
public static boolean fits(Rectangle r)
//package com.java2s; /*/*w ww. j a va 2 s. c o m*/ * ADTPro - Apple Disk Transfer ProDOS * Copyright (C) 2006 by David Schmidt * david__schmidt at users.sourceforge.net * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import java.awt.*; public class Main { /** * @param r - desired rectangle * @return true if the rectangle will fit on the screen */ public static boolean fits(Rectangle r) { boolean ret = false; final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (((r.x + r.width) <= screenSize.width) && ((r.y + r.height) <= screenSize.height)) { ret = true; } return ret; } }