I'm using NetBeans, and I have a blank JFrame
. The JFrame
is literally empty. I want this JFrame
to have round corners.
How can I do that?
if you want rounded corners, then you want a shaped frame. You can achieve that by calling Frame.setShape
. Quoting from its documentation:
The following conditions must be met to set a non-null shape:
- The
PERPIXEL_TRANSPARENT
translucency must be supported by the underlying system- The window must be undecorated (see setUndecorated(boolean) and
Dialog.setUndecorated(boolean)
)- The window must not be in full-screen mode (see
GraphicsDevice.setFullScreenWindow(Window)
)
The second of these points, an undecorated frame, corresponds to a part of your original question which was rephrased in a subsequent edit: It will give you
No windows like stuff, just the form, with no exit button, nothing.
try this. its work :)
yourframe.setBackground(new Color(0, 0, 0, 180));
yourframe.setUndecorated(true);
yourframe.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
setShape(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 80, 80));
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.