Java JComponent Container getInterior(JComponent comp)

Here you can find the source of getInterior(JComponent comp)

Description

Gets the interior drawing region of a component.

License

Apache License

Parameter

Parameter Description
comp the component to get the interior rectangle of

Return

the interior rectangle

Declaration

public static Rectangle getInterior(JComponent comp) 

Method Source Code

//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;
    }
}

Related

  1. getGlassPane(JComponent comp)
  2. getGtkStyle(Object styleFactory, JComponent component, String regionName)
  3. getGtkStyle(Object styleFactory, JComponent component, String regionName)
  4. getInputHint(JComponent comp)
  5. getInsetBounds(JComponent comp)
  6. getLocalInsetBounds(JComponent component)
  7. getMandatoryPanel(JComponent c)
  8. getMaxVisibleY(JComponent comp)
  9. getModelObject(JComponent c)