minigame.java
来自「朋友开发的一个扫雷游戏,用SWT开发的,游戏有点慢,想了解的下载看看吧」· Java 代码 · 共 89 行
JAVA
89 行
/*
* Created on 2005-6-7
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package bomb;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.SWT;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class MiniGame {
private Menu menu = null;
private Display dis = null;
private Shell shell = null;
private Game game = null;
private GameFrame gameFrame = null;
public MiniGame(){
game = new Game();
dis = new Display();
shell = new Shell(dis,SWT.CLOSE);
shell.setText("扫雷");
//shell.setLayout(new FillLayout());
GlobalInfo.init(dis);
initGameFrame(shell);
menu = new Menu(shell,SWT.BAR);
initMenu(menu);
shell.setMenuBar(menu);
shell.pack();
WidgetUtil.centerControl(shell);
shell.open();
while(!shell.isDisposed()){
if (!dis.readAndDispatch()){
dis.sleep();
}
}
dis.dispose();
}
private void initMenu(Menu menu){
MenuItem itemGame = new MenuItem(menu,SWT.CASCADE);
itemGame.setText( "游戏(&G)");
Menu menuGame = new Menu(shell,SWT.DROP_DOWN);
MenuItem itemBegin = new BeginMenuItem(menuGame,"开局(&N) \tF2",SWT.F2,game);
new MenuItem(menuGame,SWT.SEPARATOR);
MenuItem itemPrimary = new ClassMenuItem(menuGame,"初级(&P)",SWT.NONE,Game.PRIMARY,gameFrame);
MenuItem itemMiddle = new ClassMenuItem(menuGame,"中级(&M)",SWT.NONE,Game.MIDDLE,gameFrame);
MenuItem itemAdvance = new ClassMenuItem(menuGame,"高级(&A)",SWT.NONE,Game.ADVANCE,gameFrame);
new MenuItem(menuGame,SWT.SEPARATOR);
MenuItem itemOrder = new OrderMenuItem(menuGame,"扫雷英雄排行榜(&O)",SWT.NONE,shell);
new MenuItem(menuGame,SWT.SEPARATOR);
MenuItem itemExit = new ExitMenuItem(menuGame,"退出(&X)",SWT.NONE,shell);
itemGame.setMenu(menuGame);
MenuItem itemHelp = new MenuItem(menu,SWT.CASCADE);
itemHelp.setText( "帮助(&H)");
Menu menuHelp = new Menu(shell,SWT.DROP_DOWN);
MenuItem aboutItem = new AboutMenuItem(menuHelp,"关于(&G)",SWT.NONE,shell);
itemHelp.setMenu(menuHelp) ;
}
private void initGameFrame(Shell shell){
//shell.setLayout(new FillLayout());
gameFrame = new GameFrame(shell,SWT.NONE,game);
gameFrame.pack();
}
public static void main(String[] args){
new MiniGame();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?