gpt4 book ai didi

java - 是否可以在 GWT 中循环遍历网格图?

转载 作者:行者123 更新时间:2023-12-01 13:09:35 25 4
gpt4 key购买 nike

问题

我已经检查了 map 的内容、响应键,甚至尝试手动抓取 map 。但出于某种原因,它只允许我创建一张 map ,无论我选择哪一张。

我的尝试

OccupancyCheckView类

所以基本上我创建了一个对象,该对象又创建了这个 map :

private Map<String, Grid> resultGrids = new HashMap<String, Grid>(); //where String is the title of the grid

创建后,我只需允许用户抓取它:

public Map<String, Grid> getResultGrids() {
return resultGrids;
}

DataRun 类

我在另一个类中进行 RPC 调用并等待响应:

public void onSuccess(Method method, Response response) 
{
occupancyCheckView = new OccupancyCheckView(response.getResult()); //This simply passes a list of two strings which creates the titles and grids and puts them in a Map<String, Grid>

Map<String, Grid> resultGrids = occupancyCheckView.getResultGrids(); //I've checked the contents by dumping the WidgetName.toString() to the screen and BOTH grids are there yet I can't seem to call both of them at the same time

//so this is where I try accessing both grids

for( String Name : response.getResult() ) {
Label gridTitle = new Label(String.valueOf(resultGrids.containsKey(Name))); //both return back as true
gridTitle.setStyleName("gridTitle");
mainPanel_.add(gridTitle);
mainPanel_.add(resultGrids.get(Name)); //accesses the Map<String, Grid>
testMap.add(resultGrids.get(Name));
echo.setText("No Data");
}

//mainPanel_.add(resultGrids.get("FirstResponse"));
//mainPanel_.add(resultGrids.get("SecondResponse"));

}

我没有遇到编译错误。当我将各个部分打印到屏幕上时,一切正常(询问我是否要我检查任何内容)。在我注释掉两个手动添加网格的最后一部分中,如果我保留一个或两个网格,无论我选择哪一个,它仍然只显示一个网格。

编辑

如何创建网格:

private Grid occupancyGrid;

<Snip>

private void createResultGrid(List<String> gridName){

occupancyGrid = new Grid(17,17);

for (String Name_ : gridName){
Label title = new Label();
title.setText(Name_);
title.setStyleName("gridTitle"); //TODO style this

for (int index=1; index < occupancyGrid.getColumnCount(); index++){
occupancyGrid.setWidget(0, index, new HTML("Cx"+Integer.toHexString(index-1)));
}

for (int index=1; index < occupancyGrid.getRowCount(); index++){
occupancyGrid.setWidget(index, 0, new HTML("Cx"+Integer.toHexString(index-1)));
}

resultLabels.put(Name_, title);
resultGrids.put(Name_, occupancyGrid);
}
}

最佳答案

您可以添加两个网格,但第二个网格显示在第一个网格的顶部。例如,如果您的 mainPanel_ 是 LayoutPanel,则可能会发生这种情况。

尝试将两个网格添加到 FlowPanel,然后将此 FlowPanel 添加到您的 mainPanel_,或者,如果 mainPanel_ 是 LayoutPanel,请在添加时设置每个网格的位置。

关于java - 是否可以在 GWT 中循环遍历网格图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22988620/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com