Thursday, January 30, 2014

How to remove the border of a JFrame

Assuming that you 're developing an application, in which the default look-and-feel doesn't match, at all.

To be more specific, imagine the following example: I sometime wanted to develop a real-time clock JAVA application. It would be a bit ugly for the application's purpose to have the annoying border around its JFrame.

Indeed, there is a way to implement this: you just need to set the frame's undecorated method to true:   frame.setUndecorated(true);

Keep in mind that the above code has to be placed before frame's setVisible() method. Otherwise, it's like initializing the frame and then telling it to be undecorated, sth that doesn't make sense. So, you first customise the frame as you wish (undecorization, etc) and then you enable its visibility.

The full application that supports this post is related here.

No comments:

Post a Comment