Java Swing Border extendByBorder(JLabel label, Dimension dm)

Here you can find the source of extendByBorder(JLabel label, Dimension dm)

Description

extend By Border

License

Open Source License

Declaration

public static Dimension extendByBorder(JLabel label, Dimension dm) 

Method Source Code

//package com.java2s;
/* /*ww  w.j a va  2  s  .  c  om*/
 * The MIT License
 *
 * Copyright 2014 Kamnev Georgiy (nt.gocha@gmail.com).
 *
 * ??????? ????????? ?????????, ????????????, ?????, ?????????? ????? ??????? ???????????? 
 * ????????????? ? ??????????????? ???????????? (? ?????????? ?????????? "??????????? ????????????"), 
 * ????????????? ??????????? ???????????? ??? ???????????, ???????? ?????????????? ????? ?? 
 * ??????????????, ???????????, ?????????, ???????????, ??????????, ?????????????????, ?????????????????? 
 * ?/??? ??????? ????? ???????????? ?????????????, ????? ??? ? ?????, ??????? ??????????????????? 
 * ?????? ??????????? ????????????, ??? ??????????? ?????????? ????????:
 *
 * ??????????????? ???????? ? ?????? ????????? ?????? ???? ???????? ?? ???? ????? 
 * ??? ???????? ?????? ??????? ???????????? ?????????????.
 *
 * ????????? ????????????? ???????????? ???????????????? ????? ?????, ??? ?????? ????? ???????????, 
 * ????? ????????????? ??? ?????????????????, ????????, ??? ??? ???????????????? ????????????? ?????????? ????????????, 
 * ???????????? ?? ??? ????????????? ??????????????? ? ??????????????? ?????. ??? ? ?????? ??????? ??????? 
 * ??? ?????????????????? ??? ?????? ????????????????? ?? ?????? ? ??????????? ???????, ??????? 
 * ??? ?????? ???????????? ?? ??????????? ?????????????, ????????? ??? ??????, ?????????? ??, ??????? 
 * ????????? ??? ???????????? ? ????????????? ????????????? ??? ???????????????? ?????????????? ???????????? 
 * ??? ?????? ?????????? ? ????????????? ?????????????.
 */

import java.awt.Dimension;

import java.awt.Insets;

import javax.swing.JLabel;

import javax.swing.border.Border;

public class Main {

    public static Dimension extendByBorder(JLabel label, Dimension dm) {
        if (label == null) {
            throw new IllegalArgumentException("label==null");
        }
        if (dm == null) {
            throw new IllegalArgumentException("dm==null");
        }

        Border border = label.getBorder();
        if (border != null) {
            Insets insets = border.getBorderInsets(label);
            return new Dimension(dm.width + insets.left + insets.right,
                    dm.height + insets.top + insets.bottom);
        }
        return dm;
    }
}

Related

  1. createVerticalBox(Border border, Component... comps)
  2. drawBorderTrans(Graphics2D g, JComponent focusOwner, JComponent area)
  3. drawBorderWhite(Graphics2D g, JComponent focusOwner, JComponent area)
  4. drawDisabledBorder(Graphics g, int x, int y, int w, int h)
  5. drawDisabledBorder(Graphics g, int x, int y, int w, int h)
  6. findComponentWithBorder(JComponent panel, Class aClass)
  7. generatePanelWithoutBorder()
  8. getDefaultBorder()
  9. getDefaultBorderColour()