JavaFX equivalent of Swing SpringLayout

huangapple go评论103阅读模式
英文:

JavaFX equivalent of Swing SpringLayout

问题

我已经在使用Swing和SpringLayout一段时间了,我想知道JavaFX是否有与Swing SpringLayout 相当的功能,因为我计划很快将我的个人项目切换到JavaFX。

英文:

I've been working with Swing and SpringLayout for a while now and I want to know if JavaFX has equvalent of Swing SpringLayout, as I plan on swapping to JavaFX soon for my personal projects.

答案1

得分: 0

是的,您可以尝试这个链接:https://docs.oracle.com/javase/8/javafx/layout-tutorial/index.html
这是解决JavaFX中布局问题的示例。

英文:

Yes, u can try this https://docs.oracle.com/javase/8/javafx/layout-tutorial/index.html
It`s example to solve layout problem in javafx

答案2

得分: 0

JavaFX不是_Swing_。 JavaFX没有像_Swing_那样的LayoutManager概念。在_Swing_中,你可以为JPanel分配布局管理器,例如BorderLayout,但在JavaFX中,你使用BorderPane,它是一个使用特定布局的容器。我不知道JavaFX是否有像SpringLayout一样可以布局其组件的容器,但我对此表示怀疑。可能的选择是使用GridPane。无论如何,其他回答中链接的教程可能会帮助您找到合适的容器。

请记住,您不能以与编写_Swing_相同的方式编写JavaFX。您需要适应JavaFX的工作方式。例如,JavaFX使用“绑定”,而_Swing_使用“监听器”。

英文:

JavaFX is not Swing. JavaFX does not have the concept of a LayoutManager like Swing does. In Swing you assign a layout manager to a JPanel, for example BorderLayout, but in JavaFX you use a BorderPane which is a container that uses a specific layout. I don't know whether JavaFX has a container that lays out its components like SpringLayout does but I doubt it. Possibly, GridPane may be appropriate. In any case, the tutorial linked to in the other answer may help you discover an appropriate container.

Remember, you can't write JavaFX the same way you write Swing. You need to adapt to the JavaFX way of doing things. For example, JavaFX uses "bindings" while Swing uses "listeners".

huangapple
  • 本文由 发表于 2020年10月4日 00:40:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/64186611.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定