📄 testdialog.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -