- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to add Titled Border to Panel in Swing
To set Titled Border to Panel, let us first create a Panel for our Java Swing Application:
JPanel panel = new Jpanel(new BorderLayout());
Now, set the titled border:
panel.setBorder(new TitledBorder("Displaying Titled Border"));
The following is an example to add Titled Border to Panel in Swing:
Example
import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.border.TitledBorder; public class SwingDemo { public static void main(String[] args) { JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(new TitledBorder("Displaying Titled Border")); panel.add(new JButton("Demo Button"), BorderLayout.SOUTH); JOptionPane.showMessageDialog(null, panel); } }
Output
- Related Articles
- How to create titled border for a Panel in Java?
- How to add JTable to Panel in Java Swing?
- Java Program to use Soft Bevel Border in Swing
- How to set the titled justification (position title text) of the titled border in Java
- How to create Titled Border for a component in Java?
- How to change Button Border in Java Swing
- How to add a title to JTable in Java Swing?
- Java Program to create rounded borders in Swing
- How to add line border to JLabel in Java?
- How to add empty border to JPanel in Java?
- How to add a new row to JTable with insertRow() in Java Swing
- Java Program to append a row to a JTable in Java Swing
- How to add empty border to a JButton in Java?
- Java Program to create JCheckBox from text in Swing
- How can we add multiple sub-panels to the main panel in Java?

Advertisements