- 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
Draw a border around an undecorated JFrame in Java
At first, set an undecorated frame −
setUndecorated(true);
Now draw a border −
getRootPane().setBorder (.createMatteBorder(3, 3, 3, 3, Color.ORANGE));
The following is an example to draw a border around an undecorated JFrame −
Example
import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo extends JFrame { JLabel label = new JLabel("Welcome!", JLabel.CENTER); public SwingDemo() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(new Dimension(500, 300)); add(label, BorderLayout.CENTER); setUndecorated(true); getRootPane().setBorder( BorderFactory.createMatteBorder(3, 3, 3, 3, Color.ORANGE)); setVisible(true); } public static void main(String[] args) { new SwingDemo(); } }
Output
Advertisements