删除框架的标题栏以保留调整大小的机制-Java [英] Removing a Frame's title bar keeping the resize mechanims - Java

查看:57
本文介绍了删除框架的标题栏以保留调整大小的机制-Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与乔纳斯(Jonas)对下一个主题的要求有关:

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

如何在以下情况下添加对调整大小的支持使用未装饰的JFrame?

如何在JFrame上自定义标题栏? /a>

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);
}

这将返回一个这样的窗口: http://www.roseindia.net/java/example/java/swing/CreateJList.shtml (仅考虑标题栏和边框)

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?

想法是仅以边框为其边框(并重新调整大小)开始.然后,我可以使用JPanel和按钮触发关闭,最小化等OS事件来创建自定义标题栏.

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.

预先感谢您的支持.

推荐答案

您需要实现自己的鼠标侦听器并解释鼠标手势,以编程方式调整窗口大小.

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

另一种选择是使用JIDE公共层-它提供了ResizableSupport接口的多种实现,包括您所描述的ResizableFrame.

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

这篇关于删除框架的标题栏以保留调整大小的机制-Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆