BorderFactory.createTitledBorder('Title Border') : BorderFactory « Swing « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » Swing » BorderFactory 
14.109.11.BorderFactory.createTitledBorder('Title Border')Previous/Next
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;

public class Main extends JFrame {

  public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7155));

    simplePanel.setBorder(BorderFactory.createTitledBorder("Title Border"));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);
  
    
    add(simplePanel);
  }
  public static void main(String[] argv) {
    Main borderFactoryDemo = new Main();

    borderFactoryDemo.setVisible(true);
    borderFactoryDemo.pack();
  }
}
14.109.BorderFactory
14.109.1.Introducing BorderFactory
14.109.2.BorderFactory in action
14.109.3.Use BorderFactory to create borders
14.109.4.BorderFactory.createEmptyBorder
14.109.5.BorderFactory.createLineBorder: create line border
14.109.6.BorderFactory.createEtchedBorder: create Etched Border
14.109.7.BorderFactory.createEtchedBorder: LOWERED EtchedBorder
14.109.8.BorderFactory.createRaisedBevelBorder
14.109.9.BorderFactory.createLoweredBevelBorder
14.109.10.BorderFactory.createEmptyBorder(10, 10, 10, 10)
14.109.11.BorderFactory.createTitledBorder('Title Border')
14.109.12.BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLUE), "Title Line Border with color")
14.109.13.BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Title Lowered Etched Border")
14.109.14.BorderFactory.createMatteBorder(2, 5, 2, 5, Color.BLUE)
14.109.15.BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder())
14.109.16.BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), BorderFactory.createMatteBorder(-1, -1, -1, -1, icon))
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.