java菜单栏直接大小,删除框架的标题栏,保持调整大小的机制-Java

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

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 default 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值