example5_16.java

来自「书中的例题」· Java 代码 · 共 33 行

JAVA
33
字号
/* 显示提示信息框 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class MDialog extends JFrame implements ActionListener
{
  MDialog()
  {
   super("显示提示信息");
   setSize(200,200);
   setVisible(true);
   Container con=getContentPane();
   con.setLayout(new FlowLayout());
   JButton jbtn=new JButton("退出");
   con.add(jbtn);
   jbtn.addActionListener(this);
   validate();
  }
  public void actionPerformed(ActionEvent e)
   {
     String msg="你确定退出吗?";
	 int type=JOptionPane.YES_OPTION;
	 String tite="信息提示框";
	 JOptionPane.showMessageDialog(null,msg,tite,type);
	 System.exit(0); 
    }
}
//主类
public class Example5_16 
{
	public static void main(String[] args) 
	{	new MDialog();}
}

⌨️ 快捷键说明

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