Here you can find the source of buildInfoPanelTextBorder(final JLabel content, final String title)
public static JComponent buildInfoPanelTextBorder(final JLabel content, final String title)
//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); } }