Removing the Title Bar of a Frame

In this section, you will learn how to remove the title bar of a frame
or window in java. That means show the frame or window without title bar. The
title bar of the frame or window which
holds the icon, minimize button, maximize button and close button with the title
of the frame. Following is the image of the frame without title bar:

Code Description:
setUndecorated(boolean):
This is the method of the JFrame class that sets the frame
decoration. It takes a boolean typed value either true or false.
If you passes the true then the frame will undecorated means the frame
will not show the title bar and if you passes the false then the frame
will show the title bar.
Here is the code of the program:
import javax.swing.*;
public class RemoveTitleFrame{
public static void main(String[] args) {
JFrame frame = new JFrame("Removing the Title Bar of a Frame");
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setVisible(true);
}
}
|
Download this example.

|
Current Comments
6 comments so far (post your own) View All Comments Latest 10 Comments:Very good application not know how it was looking ... thanks ..
--
Java is everything.
Posted by percy on Saturday, 03.8.08 @ 21:14pm | #52036
i have used the setundecorated() as u said but the problem is iam unable to position the frame when loaded please help
Posted by kareem on Friday, 02.1.08 @ 16:05pm | #46852
frame.setUndecorated(true); must be called before any call to setVisible or pack();
Try moving frame.setUndecorated(true); to the spot right after the creation of the frame.
Posted by RandomAnon on Thursday, 09.20.07 @ 20:59pm | #28207
on using frame.setUndecorated(true);
i am getting this exception
java.awt.IllegalComponentStateException
Posted by Amarnath Anna on Thursday, 08.9.07 @ 21:09pm | #23041
on using frame.setUndecorated(true);
i am getting this exception
java.awt.IllegalComponentStateException
Posted by Nirmal on Wednesday, 08.8.07 @ 15:42pm | #22934
It is good ...It is very helpful to me...
I am waiting for this code..from last 2 days
Posted by Venkateswara Rao on Tuesday, 11.28.06 @ 11:38am | #170