testdialog.java
来自「开发一个用于进行魔方游戏的小型软件。在16个文本域中的4个随机位置上出现不多于二」· Java 代码 · 共 52 行
JAVA
52 行
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
class DialogFrame extends JFrame implements ActionListener{
JLabel jLabel2 = new JLabel("你成功啦!");
JLabel jLabel3 = new JLabel("再玩一把么?");
JButton jButton2 = new JButton("好的");
JButton jButton3 = new JButton("不了");
public DialogFrame(){
setTitle("恭喜你");
setSize(200,100);
addWindowListener(new WL());
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
contentPane.add(jLabel2);
contentPane.add(jLabel3);
contentPane.add(jButton2);
contentPane.add(jButton3);
jButton2.addActionListener(this);
jButton3.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jButton2) {
}
else if(e.getSource() == jButton3) {dispose();
}
}
}
class WL extends WindowAdapter{
public void windowClosing(WindowEvent e){System.exit(0);}
}
public class TestDialog{
public static void main(String[] args){
DialogFrame d = new DialogFrame(); d.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?