Here you can find the source of getInterior(JComponent comp)
Parameter | Description |
---|---|
comp | the component to get the interior rectangle of |
public static Rectangle getInterior(JComponent comp)
//package com.java2s; /*/*from www .j a va 2 s .c o m*/ * Copyright (C) 2012-2018 Gregory Hedlund <https://www.phon.ca> * Copyright (C) 2012 Jason Gedge <http://www.gedge.ca> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.awt.Insets; import java.awt.Rectangle; import javax.swing.JComponent; public class Main { /** * Gets the interior drawing region of a component. That is, the drawing * area inside of its border. * * @param comp the component to get the interior rectangle of * * @return the interior rectangle */ public static Rectangle getInterior(JComponent comp) { final Insets insets = comp.getInsets(); final Rectangle rect = new Rectangle(0, 0, comp.getWidth(), comp.getHeight()); rect.x += insets.left; rect.y += insets.top; rect.width -= insets.left + insets.right; rect.height -= insets.top + insets.bottom; return rect; } }