我在eclipse(服务器 - 扫雷程序)中使用gridlayout制作了一个Vaadin程序。当我在eclipse中预览时,我会看到以下内容。
当我在例如firefox中调用它时,我得到了
我认为这是调整大小或类似的问题。
public void drawBoard() {
this.removeAllComponents();
boardDTO = gameManager.getCurrentGame().getBoardDTO();
Integer w = 30 * boardDTO.getNumOfRow() + 80;
Integer h = boardDTO.getNumOfCol() * 30 + 150;
String wPx = w.toString() + "px";
String hPx = h.toString() + "px";
this.setWidth(wPx);
this.setHeight(hPx);
gridLayout = new GridLayout(boardDTO.getNumOfRow(), boardDTO.getNumOfCol());
gridLayout.setSpacing(true);
gridLayout.setMargin(true);
for (int i = 0; i < boardDTO.getNumOfRow(); i++) {
ArrayList<Cell> row = new ArrayList<Cell>();
for (int j = 0; j < boardDTO.getNumOfCol(); j++) {
Cell cell = new Cell(boardController, boardDTO.getCellDTO(i, j));
cell.setVisible(true);
row.add(cell);
gridLayout.addComponent(cell);
cell.addClickListener(cell);
boardDTO.getCellDTO(i, j).addObserver(cell);
}
grid.add(row);
}
this.addComponent(gridLayout);
}
public Cell(BoardController controller, CellDTO cellDTO) {
posX = cellDTO.getPosX();
posY = cellDTO.getPosY();
boardController = controller;
setSizeUndefined();
currentImg = BoardView.getCurrentImage(cellDTO);
//setStyleName();
loadImage();
setContent(layout);
}
@SuppressWarnings("unused")
private void loadImage() {
layout.removeAllComponents();
image = new Image("", new ThemeResource(currentImg));
image.setSizeUndefined();
Integer w=(int)getWidth();
Integer h=(int)getHeight();
//layout.setWidth(w+"px");
//layout.setHeight(h+"px");
// image.setWidth(w.toString()+"px");
// image.setHeight(h.toString()+"px");
layout.addComponent(image);
layout.setExpandRatio(image, 1.0f);
layout.setComponentAlignment(image, Alignment.MIDDLE_CENTER);
}
有任何建议如何解决这个问题。
答案 0 :(得分:0)
使用真实浏览器进行预览。 firefox的外观应该被认为是好的。您可以在常规 - > Web浏览器设置下将默认浏览器更改为eclipse中的外部Web浏览器。