- 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
How to create etched border for a component using BorderFactory class in Java?
The etched border gives an ‘etched’ look. Let’s say the following is our component −
JLabel label; label = new JLabel("This has etched border with an 'etched' look!");
Let us create an etched border with BorderFactory class −
label.setBorder(BorderFactory.createEtchedBorder());
The following is an example to create etched border for a component using BorderFactory class −
Example
package my; import javax.swing.BorderFactory; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo { public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Demo"); JLabel label; label = new JLabel("This has etched border with an 'etched' look!"); label.setFont(new Font("Arial", Font.BOLD, 18)); label.setVerticalAlignment(JLabel.CENTER); label.setBorder(BorderFactory.createEtchedBorder()); frame.add(label); frame.setSize(550,350); frame.setVisible(true); } }
Output
Advertisements