?? minigame.java
字號:
/*
* 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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -