📄 greedsnakeframe_gameover.java
字号:
package gameproject;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
public class GreedSnakeFrame_GameOver extends JDialog implements ActionListener {
GreedSnakeFrame gs;
JPanel panel1 = new JPanel();
JLabel jLabel1 = new JLabel();
XYLayout xYLayout1 = new XYLayout();
JButton button = new JButton();
BorderLayout borderLayout1 = new BorderLayout();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
public GreedSnakeFrame_GameOver(GreedSnakeFrame parent) {
gs=parent;
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
if(gs.snakeModel.levelUpgrade==true){
panel1.setLayout(xYLayout1);
this.addComponentListener(new
GreedSnakeFrame_GameOver_this_componentAdapter(this));
this.setSize(new Dimension(230, 95));
this.setTitle("Game Over");
setResizable(false);
this.getContentPane().setLayout(borderLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel1.setForeground(Color.blue);
jLabel1.setRequestFocusEnabled(true);
jLabel1.setText("太棒了!由于你的突出表现,");
button.setFont(new java.awt.Font("Dialog", 0, 15));
button.setForeground(SystemColor.desktop);
button.setText("~我知道啦~");
button.addActionListener(this);
jLabel2.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel2.setForeground(Color.blue);
jLabel2.setText("你被升职为"+gs.snakeModel.level+"了:)");
jLabel3.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel3.setForeground(Color.blue);
panel1.add(jLabel2, new XYConstraints(20, 30, 200, 20));
panel1.add(jLabel1, new XYConstraints(20, 10, 200, 20));
panel1.add(button, new XYConstraints(55, 60, 112, 30));
this.getContentPane().add(panel1, BorderLayout.CENTER);
}
else if(gs.snakeModel.recordUpgrade==true){
panel1.setLayout(xYLayout1);
this.addComponentListener(new
GreedSnakeFrame_GameOver_this_componentAdapter(this));
this.setSize(new Dimension(270, 115));
this.setTitle("Game Over");
setResizable(false);
this.getContentPane().setLayout(borderLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel1.setForeground(Color.blue);
jLabel1.setRequestFocusEnabled(true);
jLabel1.setText("靓仔表现还不错!");
button.setFont(new java.awt.Font("Dialog", 0, 15));
button.setForeground(SystemColor.desktop);
button.setText("~我知道啦~");
button.addActionListener(this);
jLabel2.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel2.setForeground(Color.blue);
jLabel2.setText("你已经把纪录刷新为"+gs.snakeModel.record+"分了!");
jLabel3.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel3.setForeground(Color.blue);
jLabel3.setText("有希望进一步加官进爵哦,继续努力!:)");
panel1.add(jLabel2, new XYConstraints(20, 30, 270, 20));
panel1.add(jLabel1, new XYConstraints(20, 10, 270, 20));
panel1.add(jLabel3, new XYConstraints(20, 50, 270, 20));
panel1.add(button, new XYConstraints(70, 80, 112, 30));
this.getContentPane().add(panel1, BorderLayout.CENTER);
}
else{
panel1.setLayout(xYLayout1);
this.addComponentListener(new
GreedSnakeFrame_GameOver_this_componentAdapter(this));
this.setSize(150, 120);
this.setTitle("Game Over");
setResizable(false);
this.getContentPane().setLayout(borderLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel1.setForeground(UIManager.getColor(
"InternalFrame.activeTitleGradient"));
jLabel1.setRequestFocusEnabled(true);
jLabel1.setText("笨!太不小心了:)");
button.setFont(new java.awt.Font("Dialog", 0, 15));
button.setForeground(SystemColor.desktop);
button.setText("~我知道啦~");
button.addActionListener(this);
panel1.add(jLabel1, new XYConstraints(30, 20, 150, 20));
panel1.add(button, new XYConstraints(30, 50, 112, 30));
this.getContentPane().add(panel1, BorderLayout.CENTER);
}
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
cancel();
}
super.processWindowEvent(e);
}
//Close the dialog
void cancel() {
dispose();
gs.paintCanvas.repaint();
}
//Close the dialog on a button event
public void actionPerformed(ActionEvent e) {
if (e.getSource() ==button) {
cancel();
}
}
void this_componentMoved(ComponentEvent e) {
gs.repaint();
}
}
class GreedSnakeFrame_GameOver_label1_componentAdapter extends java.awt.event.ComponentAdapter {
GreedSnakeFrame_GameOver adaptee;
GreedSnakeFrame_GameOver_label1_componentAdapter(GreedSnakeFrame_GameOver adaptee) {
this.adaptee = adaptee;
}
}
class GreedSnakeFrame_GameOver_this_componentAdapter extends java.awt.event.ComponentAdapter {
GreedSnakeFrame_GameOver adaptee;
GreedSnakeFrame_GameOver_this_componentAdapter(GreedSnakeFrame_GameOver adaptee) {
this.adaptee = adaptee;
}
public void componentMoved(ComponentEvent e) {
adaptee.this_componentMoved(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -