enddialog.java

来自「Java 开发的弹跳球小游戏代码. 便于理解OO的概念.」· Java 代码 · 共 52 行

JAVA
52
字号
import java.awt.*;import java.awt.event.*;/**  * Dialog box when player finishes game. * (Could enter name of winning player, if highest score, etc.) */public class EndDialog extends Dialog {        public String choice = "DONE";            private Button done;    private Button newGame;        public EndDialog (Frame frm, boolean modal, int scoreVal, int bonusVal) {        super(frm, modal);                        // Crude layout - not portable!        setLayout(new FlowLayout());            setSize(160, 150);                setFont(new Font("Fixed", Font.BOLD, 12));                add(new Label("YOUR SCORE"));                        add(new Label("Game score:  "));        add(new Label("" + scoreVal));                add(new Label("Bonus score: "));        add(new Label("" + bonusVal));                add(new Label("Total score: "));        add(new Label("" + (scoreVal + bonusVal)));                done = new Button("Done");        add(done);        done.addActionListener(new ActionListener () {            public void actionPerformed (ActionEvent e) {                choice = "DONE";                dispose();            }});                newGame = new Button("New Game");        add(newGame);        newGame.addActionListener(new ActionListener () {            public void actionPerformed (ActionEvent e) {                choice = "RESTART";                dispose();            }});            }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?