JAVA消息对话框

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;


public class XiXi extends JFrame implements ActionListener{
	JPanel jp1,jp2;
	JButton jb1,jb2;
	XiXi(){
		super("嘎嘎");
		
		jp1 = new JPanel();
		jb1 = new JButton("确定");
		jb1.addActionListener(this);
		jp1.add(jb1);
		add(jp1);
		
		jp2 = new JPanel();
		jb2 = new JButton("取消");
		jb2.addActionListener(this);
		jp2.add(jb2);
		add(jp2);
		
		
		
		setBounds(100, 100, 400, 500);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
		setLayout(new FlowLayout());
	}
	public static void main(String[] args) {
		XiXi xiXi = new XiXi();
	}
	public void actionPerformed(ActionEvent e){
		if(e.getSource() == jb1){
			JOptionPane.showMessageDialog(this, "确定","消息对话框",JOptionPane.INFORMATION_MESSAGE);
		}
			else if(e.getSource() == jb2){
				JOptionPane.showMessageDialog(this, "取消","消息对话框",JOptionPane.INFORMATION_MESSAGE);
			}
		}
}

你可能感兴趣的:(JAVA消息对话框)