How to remove the edges of a Jframe?

Asked

Viewed 1,341 times

21

I’d like to remove the edges of a JFrame. I used setUndecorated(true), however it removes completely and I would like to leave only the title bar of the JFrame.

  • 15

    +1. If there is something ready to do just that, I have never heard/seen it. Of the times I needed to create something similar, I used setUndecorated(true) and "created" the title bar with a JPanel. I used a JButton for each action button, do those events minimize/close the window is not difficult, have several examples on the internet - and of course, the possibility to customize to your taste the icons, fonts, colors, etc.

  • Ever tried to use setBorder()? put all 0?

1 answer

2

Window borders are provided by the operating system (provided the window is marked as decorated). Window decoration includes the title bar, so you can’t have one thing without the other.

There is one way to do it: you can set your window as un-decorated and implement a title bar in your hand. The problem is that you would have to make the buttons maximize, minimize and close yourself, worrying about the correct positioning of them (on Mac OS and Ubuntu is different from Window). Not to mention that you would have to do in the hand with that bar to respond when dragging and dropping. That is, it’s not worth it (but the Chrome people did!)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.