本文介绍了如何根据鼠标位置显示工具提示? - JavaFX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 stackPane
,里面有一个圆圈和几行。
I have a stackPane
, filled with a Circle and a couple of lines.
我想要显示将鼠标悬停在StackPane上时工具提示,工具提示应包含鼠标的 X / Y坐标
。
I want to display a tooltip while hovering over the StackPane and the tooltip should contain the X/Y coords
of the mouse.
我知道如何获得鼠标的Coords,但我无法找到显示工具提示的方法。
I know how to get the Coords of the mouse, but I'm unable to find a way of showing the tool tip.
你们中的任何人都可以帮助我吗?..
Can any of ou guys help me with that?..
推荐答案
试试这个...
Tooltip tp = new Tooltip("at stack tool");
stackpane.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
Node node =(Node)t.getSource();
tp.show(node, FxApp.stage.getX()+t.getSceneX(), FxApp.stage.getY()+t.getSceneY());
}
});
这篇关于如何根据鼠标位置显示工具提示? - JavaFX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!