gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:33:44 27 4
gpt4 key购买 nike

我们正在 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com