newdialog.java

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

JAVA
39
字号
import java.awt.*;import java.awt.event.*;/**  * Dialog box asking for new game. */public class NewDialog extends Dialog {        public String choice = "No";            private Button yes, no;        public NewDialog (Frame frm, boolean modal) {        super(frm, modal);                        setLayout(new FlowLayout());        // setSize(160, 100); // Omitted for cross-platform success                add(new Label("Start a new game?"));                yes = new Button("Yes");        add(yes);        yes.addActionListener(new ActionListener () {            public void actionPerformed (ActionEvent e) {                choice = "Yes";                dispose();            }});                no = new Button("No");        add(no);        no.addActionListener(new ActionListener () {            public void actionPerformed (ActionEvent e) {                choice = "No";                dispose();            }});            pack();    }}

⌨️ 快捷键说明

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