
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Can we remove the Title Bar of a Frame in Java?
Yes, we can remove the title bar of a frame using the setUndecorated() method. Set it to TRUE if you don’t want to remove the Title Bar.
The following is an example to remove the title bar of a frame in Java −
Example
package my; import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.SwingConstants; public class SwingDemo { public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Login!"); JLabel label1, label2, label3; frame.setLayout(new GridLayout(2, 2)); label1 = new JLabel("DeptId", SwingConstants.CENTER); label2 = new JLabel("SSN", SwingConstants.CENTER); label3 = new JLabel("Password", SwingConstants.CENTER); JTextField deptid = new JTextField(20); JTextField ssn = new JTextField(20); JPasswordField passwd = new JPasswordField(); passwd.setEchoChar('*'); frame.add(label1); frame.add(label2); frame.add(label3); frame.add(deptid); frame.add(ssn); frame.add(passwd); frame.setUndecorated(true); frame.setSize(550, 400); frame.setVisible(true); } }
The output is as follows. The title is hidden −
Output
Advertisements