java JavaFx 等效于 Swing JFrame
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27984081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JavaFx equivalent of Swing JFrame
提问by Nation Chirara
I am learning JavaFX. I have encountered a problem; I cannot figure out what is the equivalent of a Swing JFrame in JavaFX. Is it the Scene or the Stage?
我正在学习 JavaFX。我遇到了问题;我无法弄清楚 JavaFX 中 Swing JFrame 的等价物是什么。是场景还是舞台?
回答by dic19
The equivalent of a Swing JFrame
in JavaFX is the Stageclass which extends from Windowand can be made visible by calling show()method. The Sceneis more like the frame's content pane (not exactlythe same but similar in concept).
JFrame
JavaFX 中Swing 的等价物是Stage类,它从Window扩展而来,可以通过调用show()方法使其可见。该场景更像是框架的内容窗格(不正好相同,但概念相似)。
Off-topic
无关
A substancial difference between both frameworks is that JavaFX doesn't have dialogs such as JDialog
in Swing yet: they'll be part of the JDK8u40 which will be released on March 2015. For further details in this matter please have a read to this Marco Jakob's post: JavaFX Dialogs (official)
两个框架之间的substancial不同的是,JavaFX的没有对话,如JDialog
在Swing尚未:他们将其将于2015年三月公布进一步的细节在这个问题上的JDK8u40的一部分,请有读这个马可雅各布帖子:JavaFX Dialogs(官方)
On the other hand there are third-party options available such as ControlsFXand Marco Jakob's JavaFX dialogs, or we can play with stage's Modalityto achieve something close as exemplified here.
在另一方面也有可用的第三方选项,如ControlsFX和Marco雅各布JavaFX的对话框,或者我们也可以用舞台的演奏形态,实现了接近例证这里。