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);
			}
		}
}

posted @ 2013-01-14 20:23  N3verL4nd  阅读(199)  评论(0编辑  收藏  举报