Java Swing TitledBorder create

Description

Java Swing TitledBorder create

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.TitledBorder;

public class Main extends JFrame {

  public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComponent comp = new JLabel("Test label");
    //w w w.ja  va  2s  .  c  om
    comp.setBorder(new TitledBorder("Button"));
    getContentPane().add(comp);
    pack();

    setVisible(true);
  }

  public static void main(String arg[]) {
    new Main();
  }
}



PreviousNext

Related