简体   繁体   中英

Hiding and showing a javafx stage without losing data

So I wasn't able to find a topic on this, but it is possible to somehow make a JavaFX stage invisible, but not close / hide the stage.

For instance:

stage.hide()

Will essentially close the stage, making it so that if you want to use:

stage.show()

You'd have to reconstruct the entire stage.

To rephrase:

"Is it possible to make a JavaFX stage invisible and then visible again without losing any data?"

After some more searching I came across this topic:

JavaFX: can you create a stage that doesn't show on the task bar and is undecorated?

And as it turns out using:

// Note that this is Kotlin
stage.opacity = 0.0
stage.opacity = 1.0

Will make the stage not visible, but retain its information.

如果保留对舞台控制器的引用,则可以关闭它并使用包含所有相同信息的相同控制器创建一个新舞台。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM