Java Swing TitledBorder buildInfoPanelTextBorder(final JLabel content, final String title)

Here you can find the source of buildInfoPanelTextBorder(final JLabel content, final String title)

Description

build Info Panel Text Border

License

Open Source License

Declaration

public static JComponent buildInfoPanelTextBorder(final JLabel content, final String title) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015, 2017 Lablicate GmbH.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from  www .ja  v a 2 s.  c  o  m
 * Dr. Alexander Kerner - initial API and implementation
 *******************************************************************************/

import java.awt.BorderLayout;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;

import javax.swing.SwingConstants;

public class Main {
    public static JComponent buildInfoPanelTextBorder(final JComponent content, final String title) {

        final JPanel result = new JPanel(new BorderLayout());
        result.setBorder(BorderFactory.createTitledBorder(title));
        result.add(content, BorderLayout.CENTER);
        return result;
    }

    public static JComponent buildInfoPanelTextBorder(final JLabel content, final String title) {

        content.setHorizontalAlignment(SwingConstants.CENTER);
        content.setVerticalAlignment(SwingConstants.CENTER);
        content.setOpaque(true);
        return buildInfoPanelTextBorder((JComponent) content, title);
    }
}

Related

  1. addMarginBorder(JPanel panel, String title, int top, int left, int bottom, int right)
  2. borderTitle(JComponent component, String title)
  3. buildInfoPanelTextBorderScroll(final JComponent content, final String title)
  4. buildLabeledBorder(String label)
  5. createBorder()
  6. createBorder(String message)