如何为JavaFX中执行的特定自定义方法设置等待光标?

时间:2013-06-24 09:05:18

标签: javafx javafx-8

我使用了以下代码正在运行的代码

public void start(Stage stage) {
/* some code... */
scene.setCursor(Cursor.WAIT);
}

但我希望我自己的方法中的'scene.setCursor(Cursor.WAIT)'代码不起作用,如何在我自己的方法中设置等待光标。

以下代码我使用, 例如:

public void ImportLocalBook(Scene main) {
/* some code... */
scene.setCursor(Cursor.WAIT);
/* some code... */
}

2 个答案:

答案 0 :(得分:2)

如果您的方法中有任何可用节点,您可以通过

执行此操作
your_Node.getParent().getScene().setCursor(Cursor.WAIT);

答案 1 :(得分:0)

    setSceneCursor(parentScene, Cursor.WAIT);

above code to call the below method.. we can have below method in common place and we can access that code from anywhere if we can access class of below method

    public void setSceneCursor(Scene scene,Cursor cv)
{
scene.setCursor(cv);
}