Java Swing TitledBorder withTitledBorder(String title, JComponent c)

Here you can find the source of withTitledBorder(String title, JComponent c)

Description

Place content within a titled border

License

BSD License

Declaration

public static JPanel withTitledBorder(String title, JComponent c) 

Method Source Code

//package com.java2s;
/***// www  .  j a  v  a 2 s . c  om
 * Copyright (C) 2010 Johan Henriksson
 * This code is under the Endrov / BSD license. See www.endrov.net
 * for the full text and how to cite.
 */

import java.awt.GridLayout;

import javax.swing.*;

public class Main {
    /**
     * Place content within a titled border
     */
    public static JPanel withTitledBorder(String title, JComponent c) {
        JPanel p = new JPanel(new GridLayout(1, 1));
        p.setBorder(BorderFactory.createTitledBorder(title));
        p.add(c);
        return p;
    }
}

Related

  1. setBorder(JComponent component, String text, int titleJustification)
  2. setLabelBorder(String label, JComponent c)
  3. setPanelBorder(final JPanel p, final String s)
  4. setTitleBorder(JComponent pane, String title)
  5. titledBorder(String title, B comp)