
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 TitiledBorder Direction in Java?
To set TitleBorder direction, you need to use the constants and set it for border. For example, for direction center −
TitledBorder border = BorderFactory.createTitledBorder("Border"); border.setTitlePosition(TitledBorder.CENTER);
Above, we have set the setTitlePosition() for the direction.
The following is an example to set TitledBorder direction in Java −
Example
package my; import java.awt.BorderLayout; import java.awt.Container; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; 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); TitledBorder border = BorderFactory.createTitledBorder("Border"); border.setTitlePosition(TitledBorder.CENTER); TitledBorder border2 = new TitledBorder( border, "Above_Bottom CENTER Border", TitledBorder.CENTER, TitledBorder.ABOVE_BOTTOM); JLabel label = new JLabel(); label.setBorder(border2); Container contentPane = frame.getContentPane(); contentPane.add(label, BorderLayout.CENTER); frame.setSize(550, 300); frame.setVisible(true); } }
Output
- Related Questions & Answers
- How to set text direction in HTML?
- Can we create nested TitiledBorder in Java?
- How to set the text direction with JavaScript?
- How to traverse a C++ set in reverse direction?
- How to set the direction of the flexible items with JavaScript?
- How to set that the text direction will be submitted in HTML?
- How to set the slices of a JavaFX PieChart in anti-clockwise direction?
- Set the direction of a text with CSS
- How do we set the text direction for the content in an element in HTML?
- How to set path in Java?
- Use ListIterator to traverse an ArrayList in the forward direction in Java
- Use ListIterator to traverse an ArrayList in the reverse direction in Java
- How to search a string in backwards direction in Python?
- Program to balance the direction string so that each direction occurred quarter times in Python
- How to set file permissions in Java?
Advertisements