- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to set the titled justification (position title text) of the titled border in Java
To set the titled justification of the titled border, use the setTitleJustification() method. The following is an example to set the title justification of the titled border −
Example
package my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); LineBorder linedBorder = new LineBorder(Color.YELLOW); TitledBorder titledBorder = BorderFactory.createTitledBorder(linedBorder, "Demo Title"); titledBorder.setTitleJustification(TitledBorder.LEFT); JLabel label = new JLabel(); label.setBorder(titledBorder); Container contentPane = frame.getContentPane(); contentPane.add(label, BorderLayout.CENTER); frame.setSize(550, 300); frame.setVisible(true); } }
Output
- Related Articles
- How to create titled border for a Panel in Java?
- How to create Titled Border for a component in Java?
- Java Program to add Titled Border to Panel in Swing
- How to create Titled Pane using JavaFx?
- Java Program to set title position in Java
- How to set justification on Tkinter Text box?
- How to set the text position using geom_text in R?
- Text Justification in C++
- How to set the border colour of text object while in editing mode in FabricJS?
- How to add a title to an existing line border in Java?
- How to create JFrame with no border and title bar in Java?
- How to work with border layout position options in Java?
- How can we set the border to JComboBox items in Java?
- How to set border color for SoftBevelBorder in Java?
- How do we create the title of the text track in HTML?

Advertisements