exitdialog.java
来自「本人总结记事本的多种功能为一体,自己做了一个很全面的与大家分亨」· Java 代码 · 共 58 行
JAVA
58 行
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class ExitDialog extends JDialog implements ActionListener{
JLabel jl=new JLabel("确定要退出应用程序吗?",JLabel.CENTER);
JButton sure=new JButton("确定");
JButton cancel=new JButton("取消");
boolean exit=false;
public ExitDialog(MyNotePad nt){
super(nt,"确定退出",true);
Container c=this.getContentPane();
c.setLayout(new FlowLayout());
c.add(jl);
c.add(sure);
c.add(cancel);
sure.addActionListener(this);
cancel.addActionListener(this);
this.setBounds(450,450,200,100);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==sure)
{
exit=true;
this.dispose();
}
if(e.getSource()==cancel)
{
exit=false;
this.dispose();
}
}
public boolean getExit()
{
return exit;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?