//TFra.javaimport javax.swing.*;
import java.awt.*;
import java.awt.event.*;class frame extends JFrame
{
JTextField jtf=null;
JPasswordField jpf=null;
JButton jb=null;

frame()
{
setTitle("如果有一个为空,显示Dialog");
setBounds(250,200,400,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jtf=new JTextField();
jpf=new JPasswordField();
jb=new JButton("OK");
Container contentPane=getContentPane();
contentPane.add(jtf,BorderLayout.CENTER);
contentPane.add(jpf,BorderLayout.NORTH);
contentPane.add(jb,BorderLayout.SOUTH);

jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(jpf.getText().equals("") || jtf.getText().equals(""))
{
JDialog jd=new JDialog();
JLabel jl=new JLabel("    输入不完!!");
jd.getContentPane().add(jl);
jd.setBounds(300,250,200,100);
jd.show();
}
}
});
}
}
public class TFra
{
public static void main(String[] args)
{
frame f=new frame();
f.setVisible(true);
}

}