简体   繁体   English

在场景之间保持相同的JavaFX按钮

[英]Keep the same JavaFX buttons between scenes

I want to display the same buttons between each scene in my program but I cannot seem to find a way to do this. 我想在程序中的每个场景之间显示相同的按钮,但似乎找不到解决方法。 I want to have buttons which will be displayed on every scene but these buttons will also be used to change between scenes. 我想要有将在每个场景上显示的按钮,但是这些按钮也将用于在场景之间进行切换。

I currently have a working program but the problem is that the highlighted button does not represent which scene is currently being displayed. 我当前有一个正在运行的程序,但问题是突出显示的按钮不代表当前正在显示哪个场景。 This is because I recreate each button every time a scene is loaded therefore not keeping its old data. 这是因为每次场景加载时我都会重新创建每个按钮,因此不会保留其旧数据。

Your design is fundamentally wrong. 您的设计从根本上是错误的。 The GUI should not be used to represent the state of your system. GUI不应用于表示系统状态。 There should be some kind of model for this purpose. 为此,应该有某种模型。 Once you have created such a model it does not matter anymore how many Buttons or other GUI elements you create because they will just reflect whatever the state of your model is. 一旦创建了这样的模型,创建多少个Button或其他GUI元素就不再重要了,因为它们将只反映模型的状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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