java - 如何在 javafx8 中获取节点句柄

标签 java javafx hwnd

我们正在 Windows 中构建 JavaFX 应用程序。

我已经尝试使用 JNA Native.getComponentPointer() 方法,它与 java.awt.panel 一起工作,但我想不出一个好的方法来使用 javafx.scene.layout.Pane

执行此操作

有谁知道有什么方法可以获取 Pane 的 hWnd 吗?

最佳答案

不幸的是,我认为这在 JavaFX 中是不可能的。我能看到的唯一具有原生对等体的是舞台。您可以使用 UI 分析器工具(例如 WinSpy)或 Windows SDK 中的“inspect.exe”或“visualuiaverifynative.exe”自行验证。

来自 Mixing Heavyweight and Lightweight Components by Oracle :

There are two kinds of graphics components in the Java programming language: heavyweight and lightweight. A heavyweight component is associated with its own native screen resource (commonly known as a peer). Components from the java.awt package, such as Button and Label, are heavyweight components.

[...]

A lightweight component has no native screen resource of its own, so it is "lighter." A lightweight component relies on the screen resource from an ancestor in the containment hierarchy, possibly the underlying Frame object. Components from the javax.swing package, such as JButton and JLabel, are lightweight components.

在这种情况下,JavaFX 就像 Swing;一个轻量级工具包,其中各种 ui 组件都是用 Java 编写的,没有本地对等组件。

关于java - 如何在 javafx8 中获取节点句柄,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47900118/

相关文章:

JavaFX ComboBox 更改值导致 IndexOutOfBoundsException

windows - 确定窗口属于桌面还是 Windows 应用商店应用

java - 在 JPanel 中嵌入 HWND(窗口句柄)

C++/Win32 枚举属于我的进程的窗口并关闭它们

java - openjdk中的原生linux方法在哪里?

java - java/javascript 中浏览器选项卡的登录控件

Java 打印 "null"for String reference != to null

java - 如何检查 ObservableArray 中是否已存在具有重复 LocalDateTime 属性的对象?

eclipse - 需要Java FX Eclipse教程

java - Elasticsearch Java API - boolean 查询运算符