获取JDialog标题栏的高度? [英] Get height of JDialog title bar?

查看:88
本文介绍了获取JDialog标题栏的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得JDialog标题栏的高度?

How can I get the height of JDialog title bar?

我尝试使用getInsets().top,但是它返回0.

I've tried with getInsets().top, but it returns 0.

推荐答案

我不知道,如果您使用的是操作系统自己的窗口管理器,则可能无法实现.原因是标题栏是在Java外部绘制的.如果您确实需要此信息,则可能需要使用JNI.

I don't know if, if you're using OS's own window manager, this may not be possible. The reason is that, the title bar is drawn outside Java. If you really need this information you will probably need to use JNI.

但是,如果您使用内部框架,则可以执行以下操作

However, if you are using internal frames, you can do the following

JInternalFrame mydialog = new JInternalFrame();
((BasicInternalFrameUI)mydialog.getUI()).getNorthPane().getHeight();

但是,一个更重要的问题是,您为什么想知道?窗口系统的想法是使程序员可以从窗口环境中提取其应用程序的内容.这样一来,用户就可以动态地自定义窗口外观,在所有应用程序中看起来均一,并且不会干扰应用程序的正常运行.

But a more important question is, why do you want to know? The idea of a windowing system is so that the programmer can abstract the content of his application from the window environment. This is so that window appearances can be customised dynamically by the user, look homogeneous across all apps, and not interfere with the application's normal running.

OS和应用程序之间的这种接口将需要一个完整的消息传递API来通知窗口装饰何时发生更改等.

Such an interface between OS and app would require a whole message-passing API to inform when window decorations change etc.

这篇关于获取JDialog标题栏的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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