Java Swing TitledBorder createGuiElementBorder(final String title)

Here you can find the source of createGuiElementBorder(final String title)

Description

This method creates a titled border (used for structuring of GUI elements).

License

Apache License

Parameter

Parameter Description
title the title

Return

the border

Declaration

public static Border createGuiElementBorder(final String title) 

Method Source Code

//package com.java2s;
/**************************************************************************
 * alpha-Flow: distributed case files in form of active documents
 * (supporting knowledge-driven ad-hoc processes in healthcare)
 * ==============================================
 * Copyright (C) 2009-2012 by /*from  w  w w.ja v a  2 s  .co m*/
 *   - Christoph P. Neumann (http://www.chr15t0ph.de)
 **************************************************************************
 * 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.
 **************************************************************************
 * $Id: Swing_Helper.java 3583 2012-02-16 01:52:45Z cpn $
 *************************************************************************/

import java.awt.Color;

import javax.swing.BorderFactory;

import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

public class Main {
    /**
     * This method creates a titled border (used for structuring of GUI
     * elements).
     * 
     * @param title
     *            the title
     * @return the border
     */
    public static Border createGuiElementBorder(final String title) {
        final Border titledBorder = BorderFactory.createTitledBorder(
                BorderFactory.createMatteBorder(1, 1, 1, 1, Color.gray), title, TitledBorder.CENTER,
                TitledBorder.DEFAULT_POSITION);
        final Border emptyBoder = BorderFactory.createEmptyBorder(0, 2, 0, 2);

        return BorderFactory.createCompoundBorder(titledBorder, emptyBoder);
    }
}

Related

  1. createBorder(String message)
  2. createBorder(String title)
  3. createBorder(String title)
  4. createBorderedPanel(String title, int margin)
  5. createGroupBorder(String title)
  6. createInsetTitledBorder(String title)
  7. createStyleAttributeBorder(String title)
  8. createTitleBorder(final String title)
  9. createTitledBorder(final String title)