package com.yayu.jiemian;import java.awt.*;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.*;import com.yayu.CakeList.*;
import com.yayu.event.Event;public class Window extends JFrame implements ActionListener { JMenuBar bar;//工具栏
JMenu recordMenu;//一级菜单栏
JMenu helpMenu;
JMenuItem menuItem;//二级菜单栏
JMenuItem menuItem1;
JMenuItem menuItem2;
JMenuItem helpItem;//
JLabel cakeCodeLabel;//label控件 
JLabel cakeWeightLabel;
JTextField cakeCodeTxt;//创建文本框
JTextField cakeWeightTxt;
JButton btnOK;
JButton btnCancel;
JPanel cakePanel;
JDialog dialog;

//private static final long serialVersionUID = -3315294692244433766L;
public Window(){
Container conn=this.getContentPane();//布局管理
conn.setLayout(null);
//添加菜单栏
bar=new JMenuBar();
recordMenu=new JMenu("收银管理");
helpMenu=new JMenu("帮助");
helpItem=new JMenuItem("关于");
menuItem=new JMenuItem("收银录入");
menuItem1=new JMenuItem("报表显示");
menuItem2=new JMenuItem("退出");
bar.add(recordMenu);
bar.add(helpMenu);
helpMenu.add(helpItem);
recordMenu.add(menuItem);
recordMenu.add(menuItem1);
recordMenu.add(menuItem2);
bar.setVisible(true);
this.setJMenuBar(bar);
//添加按钮及文本输入框
cakeCodeLabel=new JLabel("商品编号:");
cakeWeightLabel=new JLabel("商品重量:");
cakeCodeTxt=new JTextField(8);
cakeWeightTxt=new JTextField(8);

btnOK=new JButton("确定");
btnCancel=new JButton("取消");
cakePanel=new JPanel();
cakePanel.add(cakeCodeLabel);
cakePanel.add(cakeCodeTxt);
cakePanel.add(cakeWeightLabel);
cakePanel.add(cakeWeightTxt);
cakePanel.add(btnOK);
cakePanel.add(btnCancel);
cakePanel.setBounds(120, 51, 180, 90);
//事件驱动
helpItem.setActionCommand("helpItem");
helpItem.addActionListener(new Event());
menuItem.addActionListener(new Event());
btnOK.addActionListener(this);
conn.add(cakePanel);
//窗口设置
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(100, 100,450,300);
this.setVisible(true);
this.setTitle("蛋糕收银系统");
this.setBackground(Color.black);

}
//
//添加事件
getValue g=new getValue();
//计算价钱
public void actionPerformed(ActionEvent e) {
String cakeNo=cakeCodeTxt.getText().trim().toUpperCase();
float cakeWeight=Float.parseFloat(cakeWeightTxt.getText());
int price=g.getPrice(cakeNo);
float totalMoney=price*cakeWeight;


//创建容器
dialog=new JDialog(this,"金额结算");//创建该窗体的对话框
JPanel pTop=new JPanel();
JPanel pNorth=new JPanel();
JPanel pBottom=new JPanel(); 
//添加控件
JLabel lTotalMoney=new JLabel("总共要付金额:"+totalMoney+"元");
pTop.add(lTotalMoney);
JLabel lRealyMoney=new JLabel("实际金额:");
pNorth.add(lRealyMoney);

JTextField txtRealyMoney=new JTextField(8);
pNorth.add(txtRealyMoney);
JButton btnSumit=new JButton("确定");
pBottom.add(btnSumit);
//将控件添加到容器中




dialog.setBounds(200,200,250,130);
dialog.getContentPane().setLayout(new BorderLayout());
dialog.getContentPane().add("North", pTop);
dialog.getContentPane().add("Center",pNorth);
dialog.getContentPane().add("South",pBottom);


dialog.getContentPane().setVisible(true);


}

}
为什么点击确定按钮的时候dialog显示不出来????帮帮忙~~谢谢了~