开发者

Removing a Frame's title bar keeping the resize mechanims - Java

My problem is related with what Jonas asked on the next topics:

How to add support for resizing when using an undecorated JFrame?

How can I customize the title bar on JFrame?

I want to create a custom window without the native title bar. This can be done by calling:

setUndecorated(true);

However, this also removes the re-size mechanism. So now I am using the next code:

 public UndecoratedFrame() {
 this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    menu.add(item);
    menuBar.add(menu);
    this.setJMenuBar(menuBar);
    this.setUndecorated(true);
    this.getRootPane().setBorder(border);
    this.setSize(400,340);
    this.setVisible(true);
}

This returns a window like this: http://www.roseindia.net/java/example/java/swing/CreateJList.shtml (Consider only the title bar and borders)

How can I remove the top title bar without removing the re-size decorator? Or should I customize the de开发者_高级运维fault title bar? How can I do this by a simple way?

The idea is to end with a frame only with its borders (and the re-size working..). Then, I can create a custom title bar with a JPanel and buttons triggering the close, minimization, etc. OS events.

Thanks in advance for your support.


You need to implement your own mouse listeners and interpret the mouse gestures, programmatically resizing the window.

Another option is to use JIDE Common Layer - it provides multiple implementations of its ResizableSupport interface, including ResizableFrame which does what you describe.

http://www.jidesoft.com/javadoc/com/jidesoft/swing/ResizableFrame.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜