Here you can find the source of CreateTitledBorderwMargin(String title, int topMargin, int leftMargin, int bottomMargin, int rightMargin)
Parameter | Description |
---|---|
title | Required title |
topMargin | (in pixel) |
leftMargin | (in pixel) |
bottomMargin | (in pixel) |
rightMargin | (in pixel) |
public static Border CreateTitledBorderwMargin(String title, int topMargin, int leftMargin, int bottomMargin, int rightMargin)
//package com.java2s; /*//w w w . ja v a2 s.c o m Part of the Papilio Java Utility Library Copyright (c) 2010-12 GadgetFactory LLC This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. 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 javax.swing.BorderFactory; import javax.swing.border.Border; public class Main { /** * Creates a Titled border having {@code title} that is on top and specified margins * around it. Margins are achieved with the help of Empty border, which just takes * space on screen and does no drawing. * * <p>This helper function was created because margins cannot be provided while * constructing a Titled border.</p> * * @param title Required title * @param topMargin (in pixel) * @param leftMargin (in pixel) * @param bottomMargin (in pixel) * @param rightMargin (in pixel) * @return the Border object */ public static Border CreateTitledBorderwMargin(String title, int topMargin, int leftMargin, int bottomMargin, int rightMargin) { Border bdrMargin = BorderFactory.createEmptyBorder(topMargin, leftMargin, bottomMargin, rightMargin); return BorderFactory.createCompoundBorder(bdrMargin, BorderFactory.createTitledBorder(title)); } }