GWT GRID表格行距问题

毛贇杰 发布于 2012/07/13 09:56
阅读 1K+
收藏 0
GWT

跟着《GWT揭秘》这书做俄罗斯方块,在创建游戏背景时候出现问题,按照书上做法生成的表格行距始终无法消除,如下图:

求消除中间白色间距的方法!

附代码:

public class TetrisPanel extends Grid{

	public TetrisPanel(int row, int col){
		super(row, col);
		this.setCellPadding(0);
		this.setCellSpacing(0);
		for (int x = 0; x < getRowCount(); x++)
			for (int y = 0; y < getColumnCount(); y++){
				Image image = new Image(TetrisSrcPath.BACKCOLOR);
				image.setPixelSize(12, 12);
				this.setWidget(x, y, image);
			}
	}
}

public class Tetris implements EntryPoint{

	public final static int ROW = 20;
	public final static int COL = 10;
	
	@Override
	public void onModuleLoad() {
		TetrisPanel tetrisPanel = new TetrisPanel(ROW, COL);
		RootPanel.get().add(tetrisPanel);
	}

}

html文件:
<!doctype html>

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Tetris Game!</title>
    <script type="text/javascript" language="javascript" src="tetris/tetris.nocache.js"></script>
  </head>
  <body>
  </body>
</html>

gwt.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='tetris'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>

  <!-- Inherit the default GWT style sheet.  You can change       -->
  <!-- the theme of your GWT application by uncommenting          -->
  <!-- any one of the following lines.                            -->
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>
  <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

  <!-- Other module inherits                                      -->

  <!-- Specify the app entry point class.                         -->
	<entry-point class='tetris.client.Tetris'/>

  <!-- Specify the paths for translatable code                    -->
  <source path='client'/>
  <source path='shared'/>

</module>

以下是问题补充:

@毛贇杰:经调试可能由生成的html代码中<td></td>之间的回车所致,求解决办法!! (2012/07/13 11:43)
加载中
0
毛贇杰
已解决:在CSS中将BODY的line-height设为0px
返回顶部
顶部