Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 可以在GWT中循环浏览网格图吗? 问题_Java_Gwt_Grid_Maps - Fatal编程技术网

Java 可以在GWT中循环浏览网格图吗? 问题

Java 可以在GWT中循环浏览网格图吗? 问题,java,gwt,grid,maps,Java,Gwt,Grid,Maps,我已经检查了地图的内容、响应键,甚至尝试手动抓取地图。但出于某种原因,它只允许我创建一个地图,无论我选择哪一个 我的尝试 职业checkview类 因此,基本上我创建了一个对象,然后创建了这个贴图: private-Map-resultGrids=new-HashMap()//其中字符串是网格的标题 创建后,我只允许用户抓取它: public Map<String, Grid> getResultGrids() { return resultGrids; }

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

我的尝试 职业checkview类

因此,基本上我创建了一个对象,然后创建了这个贴图:

private-Map-resultGrids=new-HashMap()//其中字符串是网格的标题

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

public Map<String, Grid> getResultGrids() {
        return resultGrids;
    }
publicmap getResultGrids(){
返回结果RIDS;
}
数据运行类

我在另一个类中进行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"));

            }
public void onSuccess(方法、响应)
{   
ocpencycheckview=new ocpencycheckview(response.getResult());//这只是传递一个包含两个字符串的列表,创建标题和网格,并将它们放入地图中
Map resultGrids=occuncycheckview.getResultGrids();//我已经通过将WidgetName.toString()转储到屏幕上检查了内容,两个网格都在那里,但我似乎无法同时调用它们
//这就是我尝试访问两个网格的地方
对于(字符串名称:response.getResult()){
Label gridTitle=new Label(String.valueOf(resultGrids.containsKey(Name));//两者都返回为true
gridTitle.setStyleName(“gridTitle”);
主面板添加(gridTitle);
mainPanel_u2;.add(resultGrids.get(Name));//访问映射
add(resultGrids.get(Name));
echo.setText(“无数据”);
}
//主面板添加(resultGrids.get(“FirstResponse”);
//主面板添加(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);
}
}
私有网格职业网格;
私有void createResultGrid(列表gridName){
职业网格=新网格(17,17);
for(字符串名称:gridName){
标签标题=新标签();
title.setText(名称);
title.setStyleName(“gridTitle”);//TODO此样式
for(int index=1;index
可以同时添加两个网格,但第二个网格显示在第一个网格的顶部。例如,如果主面板是布局面板,则可能会发生这种情况


尝试将两个网格添加到FlowPanel,然后将此FlowPanel添加到主面板,或者,如果主面板是布局面板,则在添加时设置每个网格的位置。

如果尚未添加,是否可以检查键是否确实不同而不相同?@Kristjan Veskimäe已添加,返回的键为
“FirstResponse”
“SecondResponse”
@KristjanVeskimäe这就是为什么我非常困惑的原因……您能否尝试在for循环的末尾为(字符串名称:response.getResult()){…break;}添加break也许您总是将第二个映射保留为所选值,因此无法更改它?如果for循环只迭代一次,那么它应该只保留第一个应为的映射different@KristjanVeskimäe-还有
//两者都返回为true
部分将返回一个false值如果您是正确的,我将创建一个FlowPan艾尔,成功了,谢谢。