?? gamepanel.java
字號:
/*
* Created on 2005-6-2
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package bomb;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import java.util.Observer;
import java.util.Observable;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class GamePanel extends Composite implements Observer{
public GamePanel(Composite parent,Game game){
super(parent,SWT.BORDER);
this.game = game;
GridLayout layout = new GridLayout();
layout.numColumns = game.getCols();
layout.makeColumnsEqualWidth = true;
layout.horizontalSpacing =1;
layout.verticalSpacing = 1;
layout.marginHeight =2;
layout.marginWidth = 2;
this.setLayout(layout);
for (int i =0 ;i<game.getRows();i++){
for (int j=0;j<game.getCols();j++){
BrickButton button = new BrickButton(this,game,i,j);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
button.setLayoutData(gridData);
game.addObserver(i,j,button);
}
}
reset();
}
public void reset(){
this.game.reset(game.getLevle());
}
public void update(Observable observable,Object object){
}
public void DigAll(){
for (int i=0;i<game.getRows();i++){
for (int j=0;j<game.getCols();j++){
game.digIt(i,j);
}
}
}
private Game game = null;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -