你是不是直接写在按钮的一个内部类中了?
下面是我的程序,你看一下。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TextDialog extends JFrame {
    JTextField txtOptName = new JTextField();
    JTextField txtLoginName = new JTextField();
    JTextField txtPassWord = new JTextField();
    JButton button = new JButton("提交");    TextDialog() {
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent we) {
                System.exit(0);
            }
        });
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                button_actionPerformed(ae);
            }
        });
        Container contpane = this.getContentPane();
        contpane.setLayout(null);
        txtOptName.setBounds(20, 30, 100, 21);
        txtLoginName.setBounds(20, 61, 100, 21);
        txtPassWord.setBounds(20, 92, 100, 21);
        button.setBounds(20, 123, 100, 21);
        contpane.add(txtOptName);
        contpane.add(txtLoginName);
        contpane.add(txtPassWord);
        contpane.add(button);
        setSize(400, 300);
        setLocation(200, 50);
    }    public static void main(String[] args) {
        TextDialog td = new TextDialog();
        td.show();
    }    public void button_actionPerformed(ActionEvent ae) {
        if (txtOptName.getText().trim().equals("")) {
            JOptionPane.showConfirmDialog(this, "操作员名不能为空", "", JOptionPane.DEFAULT_OPTION);  
               
//return  false;  
        }  
//else  
//return  true;  
 
 
//提示(在if上):"EditOpt.java":  Error  #:  550  :  statement  not  reachable  at  line  133,  column  6  
 
 
        if (txtLoginName.getText().trim().equals("")) {
            JOptionPane.showConfirmDialog(this, "操作员名不能为空", "", JOptionPane.DEFAULT_OPTION);  
//return  false;  
        }  
//else  
//return  true;  
 
//提示(在if上):"EditOpt.java":  Error  #:  550  :  statement  not  reachable  at  line  133,  column  6  
     
        if (txtPassWord.getText().trim().equals("")) {
            JOptionPane.showConfirmDialog(this, "操作员名不能为空", "", JOptionPane.DEFAULT_OPTION);  
//return  false;  
        }  
//else  
//return  true;  
    }
}