Java 如何将数组中的数据以表格形式输出
涉及到表格,估计你的数据也是二维的结构,或者是一维但可以通过某个pace转换成二维,对吧。那这样的话,source data来自于你的二维数组,target model应该就是你的表格组件背后的那个数据model,一般这种model是一个list of a kind of object.
比如有如下数组数据:
{'I','want to kiss', 'that girl'},
{'The girl','wants', 'my money'},
上面说了表格组件的model大多是一个list of object,所以这个object定义如下:
public class Event {
//Here the code doesn't confirm to the java convention. just for example.
public String who;
public String does;
public String what;
}
然后,程序大致如下:
//source data.
String[][] behaviors = new String[][]{
{'I', 'want to kiss', 'that girl'},
{'The girl', 'wants', 'my money' }
};
//fill in the model of grid.
GridDataModel model = new GridDataModel<>();
for (int i = 0; i
赞0
踩0