简体   繁体   English

如何在JavaFX GUI中显示二维数组的元素

[英]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 . 我建议使用另一个常规/主GridPaneTilePane Then put this master pane to center of BorderPane . 然后,将该主窗格放在BorderPane中心。

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

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