[英]How to display elements of a 2-d array in a JavaFX GUI
I'm extremely new JavaFX (and any GUI for that matter), and I'm having troubles with understanding some concepts. 我是非常新的JavaFX(以及与此相关的任何GUI),并且在理解某些概念时遇到了麻烦。 That said, I have 10x10 multi-dimensional array that stores random
int
's within a class that extends GridPane
, and I'm having troubles understanding how I would display each random int
value graphically in the center of a BorderPane
of another class. 就是说,我有一个10x10多维数组,它在扩展
GridPane
的类中存储随机int
,并且在理解如何在另一个类的BorderPane
中心以图形方式显示每个随机int
值时遇到了麻烦。 I would like each int
of every element to be shown in a shape of sorts uniformly. 我希望每个元素的每个
int
都以各种形状统一显示。 I don't want to know an exact solution. 我不想知道确切的解决方案。 I just want to be aware of what options and steps I should take eg imports I should be aware of etc. Found this image from a different post, but this the kind of layout I imagine, except I don't need them to be buttons
我只想知道我应该采取哪些选项和步骤,例如导入,我应该知道等等。从另一个帖子中找到了这张图片,但是我想像的是这种布局,只是我不需要它们成为按钮
Build a (probably nested) loop and traverse the 2d-array. 建立一个(可能是嵌套的)循环并遍历二维数组。 On each cycle get the int value from the class and put into one of appropriate built-in layout panes of JavaFX .
在每个循环上,从类中获取int值,并将其放入JavaFX的适当的内置布局窗格之一中 。 I suggest to use another general/master
GridPane
or TilePane
. 我建议使用另一个常规/主
GridPane
或TilePane
。 Then put this master pane to center of BorderPane
. 然后,将该主窗格放在
BorderPane
中心。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.