📄 gameframe.java
字号:
/*
* Created on 2005-1-8
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import tankgame.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class GameFrame extends JFrame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
//JPanel m_cnv=new JPanel();
//menu
/*JMenuBar jMenuBar=new JMenuBar();
JMenu jmGame=new JMenu();
JMenuItem jmiGame_Exit=new JMenuItem("Exit"),
jmiGame_Play=new JMenuItem("Play");*/
Controller controller=null;
MainGameThread mGameThread=null;
//Construct the frame with title
public GameFrame(String Title,Controller controller,MainGameThread mGameThread) {
super(Title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
this.controller=controller;
this.mGameThread=mGameThread;
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
//this.setSize(new Dimension(800, 600));
//createMenu();
//this.setJMenuBar(jMenuBar);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
mGameThread.setPlaying(false);
mGameThread.quitGame();
}
});
//m_cnv.setIgnoreRepaint(true);
this.setCursor
(Cursor.getPredefinedCursor
(Cursor.CROSSHAIR_CURSOR));
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
//mGameThread.quitGame();
System.exit(0);
}
}
/*private void createMenu() {
jmGame.setText("Game");
jmiGame_Play.setAccelerator
(KeyStroke.getKeyStroke(KeyEvent.VK_P,InputEvent.CTRL_MASK));
jmiGame_Exit.setAccelerator
(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_MASK));
jmGame.add(jmiGame_Play);
jmGame.addSeparator();
jmGame.add(jmiGame_Exit);
contentPane.add(jMenuBar);
jMenuBar.add(jmGame);
jmiGame_Play.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
mGameThread.startGame();
}
});
jmiGame_Exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
mGameThread.quitGame();
System.exit(0);
}
});
}*/
/**
* @return Returns the m_cnv.
*/
public JPanel getM_cnv() {
return this.contentPane;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -